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(parser): throw syntax error for import without arguments #5099

Merged
merged 4 commits into from
Feb 13, 2025
Merged

Conversation

fireairforce
Copy link
Member

Summary

closes: #4982

The follwing code will throw a syntax error:

type T = import;
type U = typeof import;

Test Plan

I add test case for this.

@github-actions github-actions bot added A-Parser Area: parser L-JavaScript Language: JavaScript and super languages labels Feb 12, 2025
@fireairforce
Copy link
Member Author

image

It seems the command just new-changeset will be blocked by a justfile config, I annotated it locally and generated the changeset robust.

Copy link

codspeed-hq bot commented Feb 12, 2025

CodSpeed Performance Report

Merging #5099 will not alter performance

Comparing fix-4982 (62c47cc) with main (bca10f5)

Summary

✅ 94 untouched benchmarks

@ematipico
Copy link
Member

image

It seems the command just new-changeset will be blocked by a justfile config, I annotated it locally and generated the changeset robust.

Maybe you have an old version of just installed on your machine. Try to update it and see if it solves your issue

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you for the PR. I am going to request some changes because we have a better infrastructure to handle errors, and we should use that :)

Comment on lines 1734 to 1737
p.error(p.err_builder(
format!("Expected '(', but got '{}' here", p.cur_text()),
p.cur_range(),
));
Copy link
Member

@ematipico ematipico Feb 12, 2025

Choose a reason for hiding this comment

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

That's not how we should handle the error case. You need to handle the error where parse_ts_import_type_arguments is called (line 1168) and instead of doing .ok(), you need to create a diagnostic there. The type ParsedSyntax provide methods to do so, such as or_add_diagnostic

Copy link
Member Author

Choose a reason for hiding this comment

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

ok i will fix this later

Copy link
Member Author

Choose a reason for hiding this comment

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

updated~

Base automatically changed from next to main February 12, 2025 11:41
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 50377 50377 0
Passed 49059 49059 0
Failed 1318 1318 0
Panics 0 0 0
Coverage 97.38% 97.38% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6636 6636 0
Passed 2228 2228 0
Failed 4408 4408 0
Panics 0 0 0
Coverage 33.57% 33.57% 0.00%

ts/babel

Test result main count This PR count Difference
Total 795 795 0
Passed 702 702 0
Failed 93 93 0
Panics 0 0 0
Coverage 88.30% 88.30% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18642 18642 0
Passed 14297 14297 0
Failed 4345 4345 0
Panics 0 0 0
Coverage 76.69% 76.69% 0.00%

@ematipico ematipico merged commit 9280cba into main Feb 13, 2025
13 checks passed
@ematipico ematipico deleted the fix-4982 branch February 13, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Parser Area: parser L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 type T = import; should be a syntax error
2 participants