Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Fix order of operations with ternary operations #46

Merged
merged 4 commits into from
Jul 31, 2019
Merged

Conversation

bsk26
Copy link
Contributor

@bsk26 bsk26 commented Jul 30, 2019

Description

Fixes order of operations error when oc was combined with ternary operations.

For example, previously,

oc('')('') ? 'bar' : 'bar'

would compile to,

'' != null ? '' : '' ? 'bar' : 'bar'

which would evaluate to empty string because of the order of operations on the javascript ternary operator.

This PR fixes this with an additional set of parenthesis,

('' != null ? '' : '') ? 'bar' : 'bar'

Test Plan

Test with new unit test and within the dependent codebase.
Compiled test code:
image

@bsk26 bsk26 requested a review from wielrls July 30, 2019 22:08
@wielrls
Copy link
Contributor

wielrls commented Jul 30, 2019

Can you paste example of final compiled code?

@bsk26
Copy link
Contributor Author

bsk26 commented Jul 30, 2019

Can you paste example of final compiled code?

done

wielrls
wielrls previously approved these changes Jul 30, 2019
@bsk26 bsk26 merged commit b684e88 into master Jul 31, 2019
@wielrls wielrls deleted the bsk/ocTernary branch June 5, 2020 23:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants