Preserve lexical blocks - #557
Open
Y-Nak wants to merge 3 commits into
Open
Conversation
(cherry picked from commit 2b2eeebb09dfbc12bf7c4b513b0bba9c81142ef5)
(cherry picked from commit 51305f258dbc60ca351086933baaeb276f4c311e)
(cherry picked from commit f5cb0ebe30411ddccd84fa4d99737aa464a3e078)
mbenke
requested changes
Aug 6, 2026
Collaborator
There was a problem hiding this comment.
Sadly this (still) leads to incorrect Yul:
$ ./runsol.sh test/examples/cases/block-shadowing.solc
Processing: test/examples/cases/block-shadowing.solc
Compiling to hull...
Emitting hull for contract BlockShadowing
Writing to /home/ben/work/review/build/output1.hull
Generating Yul...
writing output to /home/ben/work/review/build/block-shadowing.yul
Compiling to bytecode...
Error: Variable name x already taken in this scope.
--> build/block-shadowing.yul:25:9:
|
25 | let x
| ^^^^^
Error: solc compilation failed
ben@trawa:~/work/review$ cat /home/ben/work/review/build/block-shadowing.yul
object "BlockShadowingDeploy" {
code {
function usr$$$N126$36_36_83_55_48_36_36_36_81_81_51_55_36_78_57_36_49_48_53_95_49_49_48_95_49_49_56_95_49_49_49_95_49_48_55_95_57_55_95_57_56_95_49_48_56_95_49_48_49_95_54_36_49_48_53_95_49_49_48_95_49_49_56_95_49_49_49_95_49_48_55_95_49_48_49_95_49_36_52_53_36_84_51_57_36_78_49_48_36_49_49_54_95_57_53_95_49_48_53_95_49_49_48_95_49_48_53_95_49_49_54_95_57_53_95_53_50_95_53_55_95_53_50_95_48_36_ () {
usr$init_()
leave
}
function usr$_start () {
mstore(64, memoryguard(128))
if lt(codesize(), datasize("BlockShadowingDeploy")) {revert(0, 0)}
if callvalue() {mstore(0, 3046674083)
revert(28, 4)}
usr$$$N126$36_36_83_55_48_36_36_36_81_81_51_55_36_78_57_36_49_48_53_95_49_49_48_95_49_49_56_95_49_49_49_95_49_48_55_95_57_55_95_57_56_95_49_48_56_95_49_48_49_95_54_36_49_48_53_95_49_49_48_95_49_49_56_95_49_49_49_95_49_48_55_95_49_48_49_95_49_36_52_53_36_84_51_57_36_78_49_48_36_49_49_54_95_57_53_95_49_48_53_95_49_49_48_95_49_48_53_95_49_49_54_95_57_53_95_53_50_95_53_55_95_53_50_95_48_36_()
let size := datasize("BlockShadowing")
codecopy(0, dataoffset("BlockShadowing"), datasize("BlockShadowing"))
return(0, size)
}
function usr$init_ () { }
usr$_start()
}
object "BlockShadowing" {
code {
function usr$main () -> _result {
let x
x := 1
let x
x := 2
let directShadow
directShadow := 1
let inlineShadow
inlineShadow := 1
let inlineUpdate
inlineUpdate := 3
let updateBeforeShadow
updateBeforeShadow := 2
x := 3
_result := 3
leave
}
let _mainresult := usr$main()
mstore(0, _mainresult)
return(0, 32)
}
}
}
Collaborator
|
Proposed fix is on the yul-nesting-fix branch (commit 0b7fb9e) |
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.
Depends on #555
Retain block boundaries and local lifetimes during backend lowering.
Fixes flattened blocks that allowed locals to escape their scope or changed nested and compound assignment behavior.