summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lexer.c2
-rw-r--r--tests/custom/03_bugs/17_hang_on_unclosed_expression_block16
2 files changed, 18 insertions, 0 deletions
diff --git a/lexer.c b/lexer.c
index 6e1dcd9..616f484 100644
--- a/lexer.c
+++ b/lexer.c
@@ -1107,6 +1107,8 @@ lex_step(uc_lexer *lex, FILE *fp)
}
/* premature EOF */
+ lex->state = UT_LEX_EOF;
+
return emit_op(lex, lex->source->off, TK_ERROR, ucv_string_new("Unterminated template block"));
diff --git a/tests/custom/03_bugs/17_hang_on_unclosed_expression_block b/tests/custom/03_bugs/17_hang_on_unclosed_expression_block
new file mode 100644
index 0000000..25128bb
--- /dev/null
+++ b/tests/custom/03_bugs/17_hang_on_unclosed_expression_block
@@ -0,0 +1,16 @@
+When parsing an unclosed expression block, the lexer did end up in an
+infinite loop.
+
+-- Expect stderr --
+Syntax error: Unterminated template block
+In line 1, byte 6:
+
+ `{{ 1`
+ ^-- Near here
+
+
+-- End --
+
+-- Testcase --
+{{ 1
+-- End --