FA-90207 / Bytecode virtual machines / Member archive
Generators: yielded value left on the operand stack · case 02
Arithmetic after resumption combines the sent value with the stale yielded value.
Case contract
A generator frame runs body ops push v, pop, add, yield (pop and hand out a value, suspend), return (pop, finish with StopIteration value), try exc target / endtry (handler stack; handler "Exception" catches any thrown name). Commands: next (= send None) and send v resume; resuming a suspended frame pushes the sent value as the result of its yield; sending non-None to a never-started generator is ["TypeError"]; a finished generator answers ["StopIteration", None]. throw into a created or finished generator finishes it with ["raised", exc]; otherwise the innermost matching handler is jumped to, or the generator finishes and re-raises. close finishes the generator. Frame faults are ["vm-error"].
Why this case matters
Generator state transitions (created/suspended/done) and send/throw semantics are easy to get subtly wrong.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| yield hands out and removes the value | [["yielded", 1], ["StopIteration", 4], ["StopIteration", null]] | [["yielded", 1], ["StopIteration", 13], ["StopIteration", null]] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗