Skip to content

Commit 8262e7d

Browse files
committed
Fix literal parsing in legacy AST for older Solidity versions
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 #2215
1 parent dd46903 commit 8262e7d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

slither/solc_parsing/expressions/expression_parsing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,11 @@ def parse_expression(expression: dict, caller_context: CallerContextExpression)
445445
else:
446446
value = expression["attributes"].get("value", None)
447447
if value:
448+
# Fix for legacy AST: some older Solidity versions (e.g., 0.4.23) store
449+
# numeric literals with embedded double-quotes like '"12"' instead of '12'
450+
# Fixes: https://github.com/crytic/slither/issues/2215
451+
if isinstance(value, str) and value.startswith('"') and value.endswith('"'):
452+
value = value[1:-1]
448453
if (
449454
"subdenomination" in expression["attributes"]
450455
and expression["attributes"]["subdenomination"]

0 commit comments

Comments
 (0)