mirror of
https://github.com/swc-project/swc.git
synced 2024-11-28 02:29:04 +03:00
fix(es/parser): Don't panic on an invalid import meta property (#4994)
This commit is contained in:
parent
a2fa4a78e2
commit
53a8cb1209
@ -1155,6 +1155,10 @@ impl<I: Tokens> Parser<I> {
|
||||
None
|
||||
};
|
||||
|
||||
if obj.is_import() && !is_one_of!(self, '.', '(') {
|
||||
unexpected!(self, "`.` or `(`")
|
||||
}
|
||||
|
||||
let question_dot_token = if is!(self, '?') && peeked_is!(self, '.') {
|
||||
let start = cur_pos!(self);
|
||||
eat!(self, '?');
|
||||
|
@ -0,0 +1,3 @@
|
||||
const str = "meta";
|
||||
|
||||
console.log(import[str]);
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Unexpected token `[`. Expected `.` or `(`
|
||||
,-[$DIR/tests/errors/issue-4991/1/input.js:3:1]
|
||||
3 | console.log(import[str]);
|
||||
: ^
|
||||
`----
|
@ -0,0 +1 @@
|
||||
console.log(import?.[meta]);
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Unexpected token `?`. Expected `.` or `(`
|
||||
,-[$DIR/tests/errors/issue-4991/2/input.js:1:1]
|
||||
1 | console.log(import?.[meta]);
|
||||
: ^
|
||||
`----
|
@ -0,0 +1 @@
|
||||
console.log(import?.meta);
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Unexpected token `?`. Expected `.` or `(`
|
||||
,-[$DIR/tests/errors/issue-4991/3/input.js:1:1]
|
||||
1 | console.log(import?.meta);
|
||||
: ^
|
||||
`----
|
@ -0,0 +1 @@
|
||||
console.log(import.[meta]);
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Expected ident
|
||||
,-[$DIR/tests/errors/issue-4991/4/input.js:1:1]
|
||||
1 | console.log(import.[meta]);
|
||||
: ^
|
||||
`----
|
Loading…
Reference in New Issue
Block a user