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

Nested conditionals #99

Merged
merged 6 commits into from
Nov 30, 2023
Merged

Nested conditionals #99

merged 6 commits into from
Nov 30, 2023

Conversation

Janther
Copy link
Collaborator

@Janther Janther commented Nov 18, 2023

The current parser interprets nested ternaries in a different way as the compiler does.

// Input
a ? b : c ? d : e;

// Wrong interpretation
(a ? b : c) ? d : e;

// Correct interpretation
a ? b : (c ? d : e);

Both AST print the same code in prettier-plugin-solidity thus we haven't noticed this bug in the past.

@Janther Janther added the bug Something isn't working label Nov 18, 2023
@fvictorio
Copy link
Contributor

Thanks @Janther. I think it's better to fix this in the grammar itself. I did that in solidity-parser/antlr@37f9f9c and then undid your changes to use that instead. The tests you added still pass.

If you are ok with this, I will merge and release it.

@Janther
Copy link
Collaborator Author

Janther commented Nov 24, 2023

Much more elegant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants