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

Exponentiation should have a different prioritisation for solidity version bellow 0.8.0 #1031

Closed
Janther opened this issue Jul 3, 2024 · 1 comment · Fixed by #1037
Closed
Assignees

Comments

@Janther
Copy link

Janther commented Jul 3, 2024

originally Solidity's exponentiation had left associativity which was fixed at 0.8.0.

If I set the compiler bellow 0.8.0 I expect the output of a ** b ** c to resemble the following:

{
  "leftOperand": {
    "leftOperand": "a",
    "operator": "**",
    "rightOperand": "b"
  },
  "operator": "**",
  "rightOperand": "c"
}

Instead I the parser returns something like:

{
  "leftOperand": "a",
  "operator": "**",
  "rightOperand": {
    "leftOperand": "b",
    "operator": "**",
    "rightOperand": "c"
  }
}

This is just a simplification of the actual result but it helps as a guide.

UPDATE:
With further testing 0.5.8 works as expected while 0.7.0 has this bug. Will need to investigate further to figure out in which versions this doesn't work properly.

@Xanewok
Copy link
Contributor

Xanewok commented Jul 3, 2024

@OmarTawfik this is probably correct:

We currently define the 0.6.0 as the version that changed this:

PrecedenceExpression(
name = ExponentiationExpression,
operators = [
// Before '0.6.0', it was left-associative:
PrecedenceOperator(
model = BinaryLeftAssociative,
enabled = Till("0.6.0"),
fields = (operator = Required(AsteriskAsterisk))
),
// In '0.6.0', it became right-associative:
PrecedenceOperator(
model = BinaryRightAssociative,
enabled = From("0.6.0"),
fields = (operator = Required(AsteriskAsterisk))
)
]

However, looking at the commits upstream, it seems that 0.8.0 is only the version that changed the associativity itself: ethereum/solidity@13e7012.

What has changed in 0.6.0 are the type semantics, where the type of the base is used for the result, rather than the operand's: ethereum/solidity@33f7f96.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants