carljm / compgenerator Goto Github PK
View Code? Open in Web Editor NEWComprehension compilation fuzzer
Comprehension compilation fuzzer
We still filter out a lot of generated samples as non-compilable or not containing a listcomp. If we could constrain generation better and filter less (without excluding interesting examples), it would make the fuzzer run a lot faster.
A couple of things we should consider changing:
__a
and __b
as the names, so we can catch name mangling bugs(1)[a]
that will fail at runtime. I feel such code is less likely to be interesting, as the TypeError from the subscript could hide more interesting errors.We use recursive strategies in the AST. Currently we have an ugly hack where we first define simple strategies for List
and Tuple
that can only contain names and constants, and then later define more complex strategies that can include other expressions. This would be better handled using https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.recursive
Also, the inconsistency between use of st.from_type(NodeType)
vs directly referring to a strategy function by name had something to do with working around recursion.
The fuzzer found this (slightly simplified):
def a(b):
[(1) for b in b if (a := a)]
a("a")
On main:
>>> a("a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in a
UnboundLocalError: cannot access local variable 'a' where it is not associated with a value
On 3.11:
>>> a("a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in a
File "<stdin>", line 2, in <listcomp>
NameError: cannot access free variable 'a' where it is not associated with a value in enclosing scope
I think that's expected: previously a walrus like this would create an implicit nonlocal, but now it's just a local. Perhaps this should be documented somewhere, though it's hard to imagine real code being affected.
For the fuzzer, we should somehow ignore this difference; I'll try to think of a way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.