Fix variable redeclaration in flattened SEQ scopes#101
Merged
associate-1 merged 1 commit intomainfrom Mar 4, 2026
Merged
Conversation
When occam code declares the same variable name in separate sequential
regions (e.g. sibling SEQ blocks or repeated declarations within a proc
body), the generated Go code emitted multiple `var x type` declarations
at the same scope level, causing "redeclared in this block" errors.
Add generateStatementsWithScoping() that tracks declared names and opens
new Go { } scope blocks when a redeclaration is detected. The companion
declaredNames() helper recursively collects names from non-replicated
SEQ blocks since those are transparent in Go (no braces).
Fixes test_bell.occ and test_utils.occ transpilation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dboreham
approved these changes
Mar 4, 2026
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
var x typeat the same scope level, causingredeclared in this blockerrorsgenerateStatementsWithScoping()that tracks declared names and opens new Go{ }scope blocks on redeclaration, plusdeclaredNames()which recursively collects names from transparent (non-replicated) SEQ blockstest_bell.occ(againdeclared twice) andtest_utils.occ(chdeclared three times)Test plan
go test ./...)TestE2E_VarRedeclInSiblingSeqs— variable declared in three sibling SEQ blocks transpiles, compiles, and runs correctlytest_bell.occtranspiles and passesgo vettest_utils.occtranspiles and passesgo vetgo vet🤖 Generated with Claude Code