diff --git a/lix/libexpr/parser/grammar.hh b/lix/libexpr/parser/grammar.hh index 610df3ed2..73fe63adb 100644 --- a/lix/libexpr/parser/grammar.hh +++ b/lix/libexpr/parser/grammar.hh @@ -208,6 +208,7 @@ namespace d { // Terminators. namespace t { struct inherit : one<';'> { }; + struct binding : one<';'> { }; } } @@ -438,7 +439,7 @@ struct bindings : opt< list< sor< inherit, - seq>> + seq> >, seps > @@ -447,9 +448,9 @@ struct bindings : opt< struct repl_binding : binding {}; struct repl_bindings : seq< - list, t::sep>, + list, /* Optional semicolon at the end for convenience */ - opt> + opt > {}; struct op { diff --git a/lix/libexpr/parser/parser-impl1.inc.cc b/lix/libexpr/parser/parser-impl1.inc.cc index e9b8ded77..a1ab213b4 100644 --- a/lix/libexpr/parser/parser-impl1.inc.cc +++ b/lix/libexpr/parser/parser-impl1.inc.cc @@ -56,6 +56,7 @@ error_message_for(grammar::v1::expr::select) = "expecting selection expression"; error_message_for(grammar::v1::t::kw_then) = "expecting 'then'"; error_message_for(grammar::v1::t::kw_else) = "expecting 'else'"; error_message_for(grammar::v1::t::kw_in) = "expecting 'in'"; +error_message_for(grammar::v1::d::t::binding) = "expecting ';' to end binding"; error_message_for(grammar::v1::d::t::inherit) = "expecting ';' to end 'inherit' bindings"; struct SyntaxErrors diff --git a/tests/functional2/lang/let/in-unterminated.nix b/tests/functional2/lang/let/in-unterminated.nix new file mode 100644 index 000000000..83215f4b0 --- /dev/null +++ b/tests/functional2/lang/let/in-unterminated.nix @@ -0,0 +1,3 @@ +let + a = "" +in a diff --git a/tests/functional2/lang/let/parse-fail-unterminated.err.exp b/tests/functional2/lang/let/parse-fail-unterminated.err.exp new file mode 100644 index 000000000..924a952a0 --- /dev/null +++ b/tests/functional2/lang/let/parse-fail-unterminated.err.exp @@ -0,0 +1,6 @@ +error: syntax error, expecting ';' to end binding + at /pwd/in.nix:3:1: + 2| a = "" + 3| in a + | ^ + 4| diff --git a/tests/functional2/lang/let/test.toml b/tests/functional2/lang/let/test.toml index 77ae4290f..5fdf05b87 100644 --- a/tests/functional2/lang/let/test.toml +++ b/tests/functional2/lang/let/test.toml @@ -5,3 +5,7 @@ runner = "eval-okay" runner = "eval-okay" in = "in-ancient-let.nix" flags = [ "--extra-deprecated-features", "ancient-let" ] + +[[test]] +runner = "parse-fail" +in = "in-unterminated.nix"