Skip to content
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

Fix wrong native locations in optimized IR AST #15228

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

cameel
Copy link
Member

@cameel cameel commented Jul 1, 2024

Looks like nativeSrc in the Yul AST always matches the unoptimized source, even when the AST represents the structure of the optimized one. It's not surprising since keeping locations updated through optimizations would be pretty inconvenient for very little value, but still, I don't think users are expecting this behavior and I'd consider it a bug. I guess one could argue that the unoptimized location is the truly "native" one, but I don't think this was ever intended and does not seem very useful, since those locations are already available in the unoptimized AST.

The fix is to reparse the source again before generating the optimized AST.

Yul parsing is pretty fast so I did not bother optimizing this, but if we wanted to we could switch to not storing the IR AST and generating it on demand instead. It would save some memory too and I think that this feature is rarely used so no point in doing it eagerly.

@cameel cameel self-assigned this Jul 1, 2024
@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Jul 15, 2024
@cameel cameel removed the stale The issue/PR was marked as stale because it has been open for too long. label Jul 16, 2024
@cameel cameel force-pushed the fix-wrong-native-locations-in-ir-optimized-ast branch from 4f9bb72 to 7930290 Compare July 16, 2024 15:52
@ethereum ethereum deleted a comment from github-actions bot Jul 16, 2024
Copy link
Collaborator

@nikola-matic nikola-matic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to rebase & fix changelog clash.

libsolidity/interface/CompilerStack.cpp Outdated Show resolved Hide resolved
libsolidity/interface/CompilerStack.cpp Show resolved Hide resolved
Changelog.md Show resolved Hide resolved
@cameel cameel force-pushed the fix-wrong-native-locations-in-ir-optimized-ast branch from 7930290 to 84b89a5 Compare July 18, 2024 12:18
@cameel cameel merged commit 8e74c48 into develop Jul 18, 2024
72 checks passed
@cameel cameel deleted the fix-wrong-native-locations-in-ir-optimized-ast branch July 18, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants