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

Allow newline before type inside parens #358

Merged
merged 2 commits into from
Feb 11, 2023
Merged

Allow newline before type inside parens #358

merged 2 commits into from
Feb 11, 2023

Conversation

STRd6
Copy link
Contributor

@STRd6 STRd6 commented Feb 11, 2023

No description provided.

@STRd6 STRd6 temporarily deployed to build February 11, 2023 20:38 — with GitHub Actions Inactive
Copy link
Collaborator

@edemaine edemaine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@@ -5255,7 +5255,7 @@ TypePrimary
_? IdentifierName (Dot IdentifierName)* TypeArguments?
# NOTE: Check FunctionType before parenthesized in order to distinguish between (a: T) => U and
# A parenthesized inline interface (a: T) ---> ({a: T})
__ OpenParen Type __ CloseParen
__ OpenParen ( Type / ( EOS Type ) ) __ CloseParen
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be rewritten as follows:

Suggested change
__ OpenParen ( Type / ( EOS Type ) ) __ CloseParen
__ OpenParen ( EOS? Type ) __ CloseParen

Or maybe even simpler:

Suggested change
__ OpenParen ( Type / ( EOS Type ) ) __ CloseParen
__ OpenParen __ Type __ CloseParen

I'm a little confused why Type doesn't allow leading __ already. Ah, I see, it's because TypePrimary has lots of _? prefixes but sometimes-not-always a __ prefix. Seems a bit messy, but this should work...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want it to check Type first to handle nested implicit interfaces. __ Type would swallow the EOS and prevent Nested from matching.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Interesting! Resolved.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but maybe worth adding a comment)

@STRd6 STRd6 temporarily deployed to build February 11, 2023 20:58 — with GitHub Actions Inactive
@STRd6 STRd6 merged commit 6fe80fc into main Feb 11, 2023
@STRd6 STRd6 deleted the type-parenthetical-fix branch February 11, 2023 21:04
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