diff --git a/lix/libexpr/parser/grammar.hh b/lix/libexpr/parser/grammar.hh index 21607c15b..610df3ed2 100644 --- a/lix/libexpr/parser/grammar.hh +++ b/lix/libexpr/parser/grammar.hh @@ -203,6 +203,14 @@ struct sep : sor< using seps = star; +// Delimiters. +namespace d { + // Terminators. + namespace t { + struct inherit : one<';'> { }; + } +} + // marker for semantic rules. not handling one of these in an action that cares about // semantics is probably an error. @@ -411,7 +419,7 @@ struct inherit : _inherit, seq< t::kw_inherit, seps, opt, seps, _inherit::from, seps, must>, seps>, opt<_inherit::attrs, seps>, - must> + must > {}; struct _binding { diff --git a/lix/libexpr/parser/parser-impl1.inc.cc b/lix/libexpr/parser/parser-impl1.inc.cc index b81c23477..e9b8ded77 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::inherit) = "expecting ';' to end 'inherit' bindings"; struct SyntaxErrors { diff --git a/tests/functional2/lang/inherit/in-unterminated.nix b/tests/functional2/lang/inherit/in-unterminated.nix new file mode 100644 index 000000000..552812778 --- /dev/null +++ b/tests/functional2/lang/inherit/in-unterminated.nix @@ -0,0 +1,8 @@ +let + c = { }; + b = 2; +in { + a = b; + inherit c b + d = 5; +} diff --git a/tests/functional2/lang/inherit/parse-fail-unterminated.err.exp b/tests/functional2/lang/inherit/parse-fail-unterminated.err.exp new file mode 100644 index 000000000..c378e4bcd --- /dev/null +++ b/tests/functional2/lang/inherit/parse-fail-unterminated.err.exp @@ -0,0 +1,6 @@ +error: syntax error, expecting ';' to end 'inherit' bindings + at /pwd/in.nix:7:5: + 6| inherit c b + 7| d = 5; + | ^ + 8| }