diff --git a/lexer.c b/lexer.c index 875e5dd0..c9359b43 100644 --- a/lexer.c +++ b/lexer.c @@ -1176,8 +1176,10 @@ uc_lexer_next_token(uc_lexer_t *lex) rv = lex_step(lex); - lex->no_keyword = false; - lex->no_regexp = false; + if (rv && rv->type != TK_COMMENT) { + lex->no_keyword = false; + lex->no_regexp = false; + } return rv; } diff --git a/tests/custom/99_bugs/51_preserve_lexer_flags b/tests/custom/99_bugs/51_preserve_lexer_flags new file mode 100644 index 00000000..aba646c1 --- /dev/null +++ b/tests/custom/99_bugs/51_preserve_lexer_flags @@ -0,0 +1,20 @@ +Ensure keyword and regexp flags are preserved across comments when lexing +object literals and division operators. + +-- Testcase -- +{% + printf("%.J\n", [ + { /* comment */ default: true }, + 4 /* comment */ /2/1 + ]); +%} +-- End -- + +-- Expect stdout -- +[ + { + "default": true + }, + 2 +] +-- End --