Skip to content

Commit

Permalink
fix regex case of (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Apr 27, 2024
1 parent 864ca9d commit 3c40904
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/lexer.asm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/lexer.emcc.asm.js

Large diffs are not rendered by default.

Binary file modified lib/lexer.wasm
Binary file not shown.
9 changes: 7 additions & 2 deletions src/lexer.c
Expand Up @@ -871,7 +871,7 @@ bool readPrecedingKeywordn (char16_t* pos, const char16_t* compare, size_t n) {
}

// Detects one of case, debugger, delete, do, else, in, instanceof, new,
// return, throw, typeof, void, yield ,await
// return, throw, typeof, void, yield ,await, of
bool isExpressionKeyword (char16_t* pos) {
switch (*pos) {
case 'd':
Expand Down Expand Up @@ -908,7 +908,12 @@ bool isExpressionKeyword (char16_t* pos) {
return false;
}
case 'f':
if (*(pos - 1) != 'o' || *(pos - 2) != 'e')
if (*(pos - 1) != 'o')
return false;
// of
if (pos -2 == source || isBrOrWsOrPunctuatorNotDot(*(pos - 2)))
return true;
if (*(pos - 2) != 'e')
return false;
switch (*(pos - 3)) {
case 'c':
Expand Down
5 changes: 5 additions & 0 deletions test/_unit.cjs
Expand Up @@ -39,6 +39,11 @@ function assertExportIs(source, actual, expected) {
suite('Lexer', () => {
beforeEach(async () => await init);

test(`Regex case`, () => {
const source = `for(let t of/[0-9]+/g.exec(e)){}`
parse(source);
});

test(`Source phase imports`, () => {
const source = `
import source
Expand Down

0 comments on commit 3c40904

Please sign in to comment.