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

Bug with nested ternaries(?) #32

Closed
Jille opened this issue Oct 29, 2016 · 3 comments
Closed

Bug with nested ternaries(?) #32

Jille opened this issue Oct 29, 2016 · 3 comments
Assignees
Labels

Comments

@Jille
Copy link

Jille commented Oct 29, 2016

This expression " (2 == 2) ? 5 : (true ? 0 : 6) " fails with:
"Value '5' cannot be used with the ternary operator '?', it is not a bool"

I can only guess that it incorrectly handles the nested ternary and tries to parse the 5 as part of the Left of the second ternary.

Cool library by the way. Thanks for publishing it!

@Knetic Knetic self-assigned this Oct 30, 2016
@Knetic Knetic added bug and removed enhancement labels Oct 30, 2016
@Knetic
Copy link
Owner

Knetic commented Nov 2, 2016

Thanks for using the library!

Still looking at this. It definitely has to do with stage reordering, and in fixing the original problem I've exposed a similar problem with doubly-nested ternaries.

@Knetic
Copy link
Owner

Knetic commented Nov 3, 2016

Here we go, finally fixed as of 8a5a6dc - sorry that took so long!

The fix here should address quite a few edge cases, too. Ternaries are a bit special, and there was a flaw with how the library was deciding which part should be evaluated first. Wasn't a major flaw, but was wide enough that it would cause a bunch of random hard-to-repro bugs if not addressed.

I added a test for your use case (and it passes), so i'm closing, feel free to reopen if this reoccurs!

@Jille
Copy link
Author

Jille commented Nov 3, 2016

Thanks for the fix! It solved my issue indeed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants