Source
Jelly micro-test benchmark (PR #1304). generators scores 0% recall (0/10 named edges).
Pattern
function* gen() {
yield () => { console.log("1") }; // yields a function
yield* gen2(); // delegates to another generator
}
const x = gen();
const v1 = x.next();
v1.value(); // calls the yielded function — edge: gen.value -> <anon>
function* gen4() {
const q = yield; // receives value from .next(val)
q(); // calls the injected value
}
const y = gen4();
y.next();
y.next(() => { console.log("foo") }); // injects the callback
Named edges missed:
gen9 → gen8 (generator delegation via yield*)
gen3 → gen9 (calling a generator)
- Named generator functions calling each other
What's needed
- Track
yield expr — the expression becomes available as .next().value at the call site
- Track
yield* — delegates the generator, so edges from the delegate apply to the caller too
- Track values passed via
.next(val) — the value becomes the result of the yield expression
Generators are a challenging dataflow problem, but a simpler first step:
resolve named generator function calls (e.g., gen9 → gen8 when one generator yield*s another named generator).
Impact
- 10 named edges in
generators fixture
- Generator-based code (async iterators, Redux sagas, koa middleware) is common
Fixture
tests/benchmarks/resolution/fixtures/jelly-micro/generators/generators.js
References
Source
Jelly micro-test benchmark (PR #1304).
generatorsscores 0% recall (0/10 named edges).Pattern
Named edges missed:
gen9 → gen8(generator delegation viayield*)gen3 → gen9(calling a generator)What's needed
yield expr— the expression becomes available as.next().valueat the call siteyield*— delegates the generator, so edges from the delegate apply to the caller too.next(val)— the value becomes the result of theyieldexpressionGenerators are a challenging dataflow problem, but a simpler first step:
resolve named generator function calls (e.g.,
gen9 → gen8when one generatoryield*s another named generator).Impact
generatorsfixtureFixture
tests/benchmarks/resolution/fixtures/jelly-micro/generators/generators.jsReferences