Skip to content

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
@Janther Janther requested a review from fvictorio November 18, 2023 01:32
@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.

3 participants