Fix object-literal generator method typing; extend generator .next() test coverage - #243
Merged
Merged
Conversation
…hance test coverage for generator methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{ *gen() {...} },{ gen: function*(){} }) typing a call's return as the bare yield-tuple[value, done]instead of the generator wrapper object, which broke.next()/for...of. Class generator methods already worked; root cause wasprocessObjectFunctionLikeProtocomputing the field type viamlirGenFunctionPrototypedirectly instead of going through the generator-aware dispatch class methods use. Fix extracts abuildGeneratorWrapperDeclarationhelper (behavior-preserving refactor ofmlirGenFunctionGenerator) and routes object-literal generator methods through it for prototype typing too.00generator7.ts: object-literal + class generator methods, manual.next()on a class generator method, independent-instance isolation.00generator_manual_next2.ts: interleaved independent generator instances, single-drain-via-helper-function, generator body closing over/mutated by outer state between resumptions, post-completion.next()calls.Known follow-up (not fixed here, documented in-repo)
Passing a generator as a function parameter and calling
.next()inside the callee mutates a private copy — the caller's generator does not advance afterward. Generator objects have value semantics and are copied across the parameter ABI boundary, unlike same-functionconstlocals (which reuse one alloca via a materialization cache). A real fix needs pass-by-reference semantics for generator/mutable-object parameters inmlirGenFunctionParams— broader in scope, deliberately out of scope for this PR. See the comment abovedrainTwoin00generator_manual_next2.ts.Test plan
ctest -R generator -j4— 18/18 passedctest -R ^test-jit- -j8— 350/350 passedctest -R ^test-compile- -j8— 354/354 passed