parser: improve error message for missing semicolon in inherit
Before: error: syntax error, expecting ';' After: error: syntax error, expecting ';' to end 'inherit' bindings Change-Id: I47c633cb5c696b646840c58e03270a7d6a6a6964
This commit is contained in:
@@ -203,6 +203,14 @@ struct sep : sor<
|
||||
|
||||
using seps = star<t::sep>;
|
||||
|
||||
// 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<one<'('>, seps, _inherit::from, seps, must<one<')'>>, seps>,
|
||||
opt<_inherit::attrs, seps>,
|
||||
must<one<';'>>
|
||||
must<d::t::inherit>
|
||||
> {};
|
||||
|
||||
struct _binding {
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
let
|
||||
c = { };
|
||||
b = 2;
|
||||
in {
|
||||
a = b;
|
||||
inherit c b
|
||||
d = 5;
|
||||
}
|
||||
@@ -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| }
|
||||
Reference in New Issue
Block a user