Parsing for safe call expressions, existential expressions #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Safe calls
Safe tilde calls
Existential expressions
@rattrayalex Putting this here for you to look at, can be seprated out if desired.
x?
(note non-strict eq)
Notes
Whitespace is not permitted before the
?
in existentials or safe calls, and not permitted between the?(
in safecalls either. If there is whitespace present it will be parsed as a ternary.There is one grammatical ambiguity due to flow type casting. In vanilla JS,
(a?(b):c)
is parsed as a ternary -- here it is now being parsed as a Flow typecast of a safecall.Note that this ambiguity is incredibly obscure. It only takes place if the whole expr is wrapped in parens (as is required for a flow typecast) AND the consequent is wrapped in parens AND no spaces are put on either side of the
?
. In fact this ambiguity does not arise in any of the babylon fixtures and I had to discover it on my own.