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

Add more tests of chain expressions. #783

Merged
merged 2 commits into from
Oct 12, 2020
Merged

Conversation

benjamn
Copy link
Owner

@benjamn benjamn commented Oct 12, 2020

Follow-up to #766, addressing a few issues:

  1. The ChainElement type is an abstract supertype of CallExpression and MemberExpression (see Added ChainExpression type ast-types#399), so switch (n.type) will always see either "CallExpression" or "MemberExpression" and never "ChainElement".

  2. We need to keep the printing of {Member,Call}Expression aligned with the printing of Optional{Member,Call}Expression, at least until the latter types are fully deprecated by all parsers.

  3. The optionality logic for call expressions was slightly off. Whether a ?. is printed should not depend on the optionality of n.callee. This has been an issue since Implement printer cases for Optional{Member,Call}Expression. #511, per git blame.

@benjamn benjamn self-assigned this Oct 12, 2020
Three issues:

1. The ChainElement type is an abstract supertype of CallExpression and
   MemberExpression, so `switch (n.type)` will always see either
   "CallExpression" or "MemberExpression" and never "ChainElement".

2. We need to print {Member,Call}Expression the same way we print
   Optional{Member,Call}Expression, at least until the latter types are
   fully deprecated by all parsers.

3. The optionality logic for call expressions was slightly off. Whether a
   ?. is printed should not depend on the optionality of the callee. This
   has been an issue since #511, per git blame.
@benjamn benjamn merged commit 2107242 into master Oct 12, 2020
@benjamn benjamn deleted the more-tests-of-chain-expressions branch October 12, 2020 17:56
@benjamn benjamn mentioned this pull request Oct 12, 2020
@benjamn
Copy link
Owner Author

benjamn commented Oct 12, 2020

@eventualbuddha Thanks for the review!

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

Successfully merging this pull request may close these issues.

2 participants