Scope loop flags and specialization thisType override to local contexts (A6 phase 2a)#211
Merged
Merged
Conversation
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
A6 phase 2 (copy-on-override), first field group — and both converted sites turned out to be live examples of the latent-leak bug class the plan predicted.
DoStatement/WhileStatement/ForStatementnow setisLoop/loopLabelon a localloopGenContextpassed to their condition/body/incrementor generation (including thefor awaitasync-execute body, which now copies from the loop context). Previously they mutated the caller's context throughconst_castand never restored — after the first loop in a function,isLoopstayedtruefor all subsequent code, affecting themlirGenDisposableLoopScope walk.instantiateSpecializedFunction. The arrow/function-expressionthisType = nullptrprotection now applies to a function-local context copy (the whole body usesinstantiateGenContext); previously the null leaked into the caller's context permanently, which could breakthisaccess in code following a generic-arrow instantiation inside a method.Deliberately unchanged:
loopLabelis still assigned afterlabelwas cleared (always empty — pre-existing oddity, preserved; the label still reaches the loop op viaLABEL_ATTR_NAME). Remainingconst_castsites are the mailbox-pattern fields (generatedStatements×4,typeAliasMap×2,mlirGenParametersthisType) for the next slice — those intentionally communicate upward and need honest signatures rather than copies.Test plan
tslangrebuilt cleanly (vs2026 debug)continue outer— JIT output12 4 3 3as expectedMLIRGenTests.exe: 12/12 pass🤖 Generated with Claude Code