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

fix: improve diagnose for invalid generic function call #2781

Closed

Conversation

HerrCai0907
Copy link
Member

Original implement treat invalid generic function call Expr '<' Expr '>' '(' ')' as less than and greater expression.
This patch detect it and throw "expect type" diagnose.

Fixes #2780

Copy link
Member

@CountBleck CountBleck left a comment

Choose a reason for hiding this comment

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

Arguably, this seems like a hack, since it's special-casing those sets of tokens.

Also, a<12345>() is valid TS, since 12345 is a type (but we don't support that!).

The proper fix would be implementing the typeof syntax in types (with a "Not yet implemented" diagnostic).

Also, TS seems to dislike this bit of code, but this patch would erroneously treat it as a call to a generic function.

@HerrCai0907
Copy link
Member Author

@CountBleck

  1. typeof will return a string of type instead of type.
  2. If we wan to do some developer friendly diagnostic messages, hack is necessary. Otherwise we will get expect =>.

we will try to parser it as generic function call, and than treat it as comparison. If both patterns aren't matched, than we need to do some hack and guess what is the actual intention.

@HerrCai0907
Copy link
Member Author

Also, TS seems to dislike this bit of code, but this patch would erroneously treat it as a call to a generic function.

This code will not match this pattern. It only match empty parentheses and it is definitely not a comparison.

@HerrCai0907 HerrCai0907 deleted the HerrCai0907/issue2780 branch November 27, 2023 14:25
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.

Parser error, i think
2 participants