-
Notifications
You must be signed in to change notification settings - Fork 199
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
Incorrect location generated when desugaring arithmetic assign ops (e.g., a += b
)
#1521
Comments
For what it's worth, from a client perspective I think there is strong value added for an AST library to not do this desugaring of For instance, there is no way for me to access the location of the Anyway, not the point of this issue, just my two cents |
You're right, we should have an |
Describe the bug
An expression
a += b
is parsed as apt::Expression::AssignAdd{left, right}
. When this is translated from apt
to anast
it is desugared into anAssign { ..., Expression::Add { left, right}}
. Whenleft
is a Storage access,left
's location is wrong when it gets desugared: it ends up spanning the entireAssignAdd
expression instead of just the left expression.To Reproduce
I have a repository that reproduces the bug.
Hyperledger Solang version
Include the complete solidity source code
Additional context
Running my code visits each binary expression (after desugaring), and checks to ensure that the
left.loc().end() < right.loc.start()
, and if not, prints an error. This is the output of my test on the above program:It's clear that the bug exists only when the LHS of an op-assign (
+=
,|=
) is a storage access. This does not occur for local variables.The text was updated successfully, but these errors were encountered: