-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Disallow shadowing for all identifiers in inline assembly #11735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
85448c8 to
a88a11f
Compare
.../libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol
Show resolved
Hide resolved
|
Can you add a test with variable in inline assembly that shadows local variable? |
that already exists: test/libsolidity/syntaxTests/inlineAssembly/shadowing/local_variable.sol |
mijovic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
|
Would like to get some more thumbsup since this can break existing contracts (see the tests). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this is a breaking change. Since it's only present in Yul codegen, we could prolong the fix to breaking.
| uint x; | ||
| function f() public pure { | ||
| assembly { | ||
| function g(f) -> x {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this wouldn't trigger the bug from the issue. But it's fine as long as such examples don't reach codegen.
| { | ||
| SecondarySourceLocation ssl; | ||
| for (auto const* decl: declarations) | ||
| ssl.append("The shadowed declaration is here:", decl->location()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
contract C {
function f() external {
assembly {
function g(gasleft) { gasleft := 2 }
}
}
}The decl->location would be empty.
Should we do something about global functions?
|
Ok, true, let me try to fix it in yul codegen in a different way. |
a88a11f to
5948fed
Compare
8a2b7bf to
5072e6c
Compare
ekpyron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a test case for function arguments colliding with local variables (it's implicitly covered, but might be nice to have explicitly), maybe some other cases, too.
But generally, looks good!
5072e6c to
aeb2438
Compare
Manual Resolved Conflicts: Changelog.md * Updated changelog test/externalTests/ens.sh * Merged fixes for upstream from both develop and breaking test/libsolidity/semanticTests/inlineAssembly/external_identifier_access_shadowing.sol * Removed in #11735 (breaking) test/libsolidity/semanticTests/inlineAssembly/function_name_clash.sol * Removed in #12209 (breaking) test/libsolidity/semanticTests/storage/mappings_array2d_pop_delete.sol * Removed in #11843 (breaking) test/libsolidity/semanticTests/storage/mappings_array_pop_delete.sol * Removed in #11843 (breaking) test/libsolidity/syntaxTests/inlineAssembly/basefee_berlin_function.sol * Used version of file from #11842 (breaking)
Uh oh!
There was an error while loading. Please reload this page.