Skip to content

Commit 50bff18

Browse files
author
Laura van Luyn
committed
add support for regexp test after do while loop with semicolon
1 parent f56fd5c commit 50bff18

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

dist/meriyah.umd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5392,7 +5392,7 @@
53925392
consume(parser, context | 32768, 67174411);
53935393
const test = parseExpressions(parser, context, 0, 1, parser.tokenPos, parser.linePos, parser.colPos);
53945394
consume(parser, context | 32768, 16);
5395-
consumeOpt(parser, context, 1074790417);
5395+
consumeOpt(parser, context | 32768, 1074790417);
53965396
return finishNode(parser, context, start, line, column, {
53975397
type: 'DoWhileStatement',
53985398
body,

src/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ export function parseBlock(
823823

824824
consume(parser, context | Context.AllowRegExp, Token.RightBrace);
825825

826-
const blockNode = <ESTree.BlockStatement> finishNode(parser, context, start, line, column, {
826+
const blockNode = <ESTree.BlockStatement>finishNode(parser, context, start, line, column, {
827827
type: 'BlockStatement',
828828
body
829829
});
@@ -1882,7 +1882,7 @@ export function parseDoWhileStatement(
18821882
// The previous token is ) and the inserted semicolon would then be parsed as the terminating semicolon of a do-while statement (13.7.2).
18831883
// This cannot be implemented in matchOrInsertSemicolon() because it doesn't know
18841884
// this RightRaren is the end of a do-while statement.
1885-
consumeOpt(parser, context, Token.Semicolon);
1885+
consumeOpt(parser, context | Context.AllowRegExp, Token.Semicolon);
18861886
return finishNode(parser, context, start, line, column, {
18871887
type: 'DoWhileStatement',
18881888
body,

test/parser/statements/do-while.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,55 @@ while(y)
718718
}
719719
]
720720
}
721+
],
722+
[
723+
'do { } while (a); /^.*$/.test(b)',
724+
Context.OptionsWebCompat,
725+
{
726+
type: 'Program',
727+
sourceType: 'script',
728+
body: [
729+
{
730+
type: 'DoWhileStatement',
731+
body: {
732+
type: 'BlockStatement',
733+
body: []
734+
},
735+
test: {
736+
type: 'Identifier',
737+
name: 'a'
738+
}
739+
},
740+
{
741+
type: 'ExpressionStatement',
742+
expression: {
743+
type: 'CallExpression',
744+
callee: {
745+
type: 'MemberExpression',
746+
object: {
747+
type: 'Literal',
748+
value: /^.*$/,
749+
regex: {
750+
pattern: '^.*$',
751+
flags: ''
752+
}
753+
},
754+
computed: false,
755+
property: {
756+
type: 'Identifier',
757+
name: 'test'
758+
}
759+
},
760+
arguments: [
761+
{
762+
type: 'Identifier',
763+
name: 'b'
764+
}
765+
]
766+
}
767+
}
768+
]
769+
}
721770
]
722771
]);
723772
});

0 commit comments

Comments
 (0)