Fix literal parsing in legacy AST for older Solidity versions#2953
Open
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
Open
Fix literal parsing in legacy AST for older Solidity versions#2953ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
Conversation
Some older Solidity versions (e.g., 0.4.23) store numeric literal values in the legacy AST with embedded double-quotes like '"12"' instead of '12'. This caused parsing failures for fixed-size array declarations like `uint256[12]` when computing storage layout. The fix strips surrounding double-quotes from literal values in the legacy AST parsing path. Fixes crytic#2215
8262e7d to
633504f
Compare
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
Root Cause
In Solidity versions like 0.4.23, the legacy AST format stores numeric literal values with embedded double-quotes. For example, the array declaration
uint256[12]has its length stored as'"12"'(with quote characters) instead of just'12'.This caused
ValueError: invalid literal for int() with base 10: '"12"'when computing storage layout.Fix
Strip surrounding double-quotes from literal values when parsing legacy AST (lines 447-450 in expression_parsing.py).
Test Case
This should now parse without errors.
Fixes #2215