diff --git a/lix/libexpr/parser/grammar.hh b/lix/libexpr/parser/grammar.hh index 73fe63adb..cd549f150 100644 --- a/lix/libexpr/parser/grammar.hh +++ b/lix/libexpr/parser/grammar.hh @@ -209,6 +209,7 @@ namespace d { namespace t { struct inherit : one<';'> { }; struct binding : one<';'> { }; + struct attrs : one<'}'> { }; } } @@ -401,7 +402,7 @@ struct _attr { struct expr : semantic, seq< TAO_PEGTL_STRING("${"), seps, must, seps, - must> + must > {}; }; struct attr : _attr, sor< @@ -505,7 +506,7 @@ struct _expr { Init..., OpenMod>, seps, bindings, seps, - must> + must > {}; struct select; diff --git a/lix/libexpr/parser/parser-impl1.inc.cc b/lix/libexpr/parser/parser-impl1.inc.cc index a1ab213b4..41e070e4d 100644 --- a/lix/libexpr/parser/parser-impl1.inc.cc +++ b/lix/libexpr/parser/parser-impl1.inc.cc @@ -58,6 +58,7 @@ 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"; +error_message_for(grammar::v1::d::t::attrs) = "expecting '}' to end attribute set"; struct SyntaxErrors { diff --git a/tests/functional2/lang/assets/test_lang_infra/runner_ef.err.exp b/tests/functional2/lang/assets/test_lang_infra/runner_ef.err.exp index e322e0b44..a65fa228a 100644 --- a/tests/functional2/lang/assets/test_lang_infra/runner_ef.err.exp +++ b/tests/functional2/lang/assets/test_lang_infra/runner_ef.err.exp @@ -1,4 +1,4 @@ -error: syntax error, unexpected end of file, expecting '}' +error: syntax error, unexpected end of file, expecting '}' to end attribute set at /pwd/in.nix:1:2: 1| { | ^ diff --git a/tests/functional2/lang/assets/test_lang_infra/runner_pf.err.exp b/tests/functional2/lang/assets/test_lang_infra/runner_pf.err.exp index e322e0b44..a65fa228a 100644 --- a/tests/functional2/lang/assets/test_lang_infra/runner_pf.err.exp +++ b/tests/functional2/lang/assets/test_lang_infra/runner_pf.err.exp @@ -1,4 +1,4 @@ -error: syntax error, unexpected end of file, expecting '}' +error: syntax error, unexpected end of file, expecting '}' to end attribute set at /pwd/in.nix:1:2: 1| { | ^ diff --git a/tests/functional2/lang/attrs/in-unterminated.nix b/tests/functional2/lang/attrs/in-unterminated.nix new file mode 100644 index 000000000..4c5f29a89 --- /dev/null +++ b/tests/functional2/lang/attrs/in-unterminated.nix @@ -0,0 +1,2 @@ +{ + a = "b"; diff --git a/tests/functional2/lang/attrs/parse-fail-unterminated.err.exp b/tests/functional2/lang/attrs/parse-fail-unterminated.err.exp new file mode 100644 index 000000000..d22c111d1 --- /dev/null +++ b/tests/functional2/lang/attrs/parse-fail-unterminated.err.exp @@ -0,0 +1,5 @@ +error: syntax error, unexpected end of file, expecting '}' to end attribute set + at /pwd/in.nix:3:1: + 2| a = "b"; + 3| + | ^