Hoist Hole conditions and fix while loop variable scoping#670
Draft
joehendrix wants to merge 2 commits intomainfrom
Draft
Hoist Hole conditions and fix while loop variable scoping#670joehendrix wants to merge 2 commits intomainfrom
joehendrix wants to merge 2 commits intomainfrom
Conversation
When if/while conditions translate to Hole (e.g., subscript expressions), hoist them into a fresh variable declaration to avoid free variable errors in Core type checking. Fix while loop variable hoisting: emit declarations as separate statements in the parent scope rather than wrapped in a Block, so variables assigned inside the loop body remain in scope after the loop (matching Python scoping semantics). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add 2 end-to-end tests: - test_while_var_scope.py: variable declared inside while loop body accessed after the loop (Python scoping) - test_unlifted_hole.py: non-modeled call nested in keyword argument produces Hole that gets hoisted to avoid free variable errors Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
This seems (at least from the PR description) similar to #639 . Can you explain the difference? |
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
Hole(e.g., from subscript expressions likedict[key]), it's hoisted into a fresh variable declaration. This prevents free variable errors during Core type checking.Test plan
lake buildpasses cleanlyBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
🤖 Generated with Claude Code