Move new variables declaration out of if , else, while and for blocks#619
Merged
thanhnguyen-aws merged 8 commits intostrata-org:mainfrom Mar 20, 2026
Merged
Conversation
joehendrix
previously approved these changes
Mar 20, 2026
Contributor
joehendrix
left a comment
There was a problem hiding this comment.
Looks good — clean refactoring and the if/else hoisting correctly mirrors the try/except pattern. Two minor non-blocking notes inline.
shigoel
previously approved these changes
Mar 20, 2026
andrewmwells-amazon
approved these changes
Mar 20, 2026
if and else blocksif , else, while and for blocks
shigoel
approved these changes
Mar 20, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 27, 2026
…639) *Description of changes:* This PR move all variable declarations to the beginning of the function body. This PR continues the local variable bug fix from this PR #619. PR #619 moves the variable declarations inside the body blocks of `if`, `while`, and `for` statements and attach them on the top of those statements. However, in case those `if`, `while`, and `for` statements are inside a sub-block, those variables are not accessible outside of that block. This PR resolves that issue by collecting all variables that appear inside a function body and making declarations for them at the top of the function body. Note: To accommodate this task, this PR also adds overloaded types to compositeTypeNames so that isCompositeType recognizes them during type inference. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --------- Co-authored-by: Shilpi Goel <shigoel@gmail.com>
olivier-aws
pushed a commit
that referenced
this pull request
Mar 30, 2026
…639) *Description of changes:* This PR move all variable declarations to the beginning of the function body. This PR continues the local variable bug fix from this PR #619. PR #619 moves the variable declarations inside the body blocks of `if`, `while`, and `for` statements and attach them on the top of those statements. However, in case those `if`, `while`, and `for` statements are inside a sub-block, those variables are not accessible outside of that block. This PR resolves that issue by collecting all variables that appear inside a function body and making declarations for them at the top of the function body. Note: To accommodate this task, this PR also adds overloaded types to compositeTypeNames so that isCompositeType recognizes them during type inference. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --------- Co-authored-by: Shilpi Goel <shigoel@gmail.com>
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.
Description of changes: This PR remove new variables declaration inside
if,else,whileandforblocks and attach them before the those statements because Python allows using those variables outside of those blocks (they are not local).By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.