diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-12-06 10:10:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-06 10:10:11 +0100 |
commit | 9150505f46bc9cbe33e31ad4475aedbf0584a431 (patch) | |
tree | 6b70cbe728dc9d18f6f4e43ed181298467875b84 | |
parent | 3f7035c4b294a41609b8562ace08a89b40225492 (diff) | |
parent | 9bcd25f54708c2d6bde79f266f1b74d432f4571f (diff) |
Merge pull request #251 from jow-/fix-parsing-kwlabels-after-comments
lexer: Preserve keyword, regexp flags until processing non-comment to…
-rw-r--r-- | lexer.c | 6 | ||||
-rw-r--r-- | tests/custom/99_bugs/51_preserve_lexer_flags | 20 |
2 files changed, 24 insertions, 2 deletions
@@ -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 0000000..aba646c --- /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 -- |