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 for regexp test after do-while with semicolon #250

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ export function parseDoWhileStatement(
// The previous token is ) and the inserted semicolon would then be parsed as the terminating semicolon of a do-while statement (13.7.2).
// This cannot be implemented in matchOrInsertSemicolon() because it doesn't know
// this RightRaren is the end of a do-while statement.
consumeOpt(parser, context, Token.Semicolon);
consumeOpt(parser, context | Context.AllowRegExp, Token.Semicolon);
return finishNode(parser, context, start, line, column, {
type: 'DoWhileStatement',
body,
Expand Down
49 changes: 49 additions & 0 deletions test/parser/statements/do-while.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,55 @@ while(y)
}
]
}
],
[
'do { } while (a); /^.*$/.test(b)',
Context.OptionsWebCompat,
{
type: 'Program',
sourceType: 'script',
body: [
{
type: 'DoWhileStatement',
body: {
type: 'BlockStatement',
body: []
},
test: {
type: 'Identifier',
name: 'a'
}
},
{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
object: {
type: 'Literal',
value: /^.*$/,
regex: {
pattern: '^.*$',
flags: ''
}
},
computed: false,
property: {
type: 'Identifier',
name: 'test'
}
},
arguments: [
{
type: 'Identifier',
name: 'b'
}
]
}
}
]
}
]
]);
});