parser: improve error message for missing semicolon in let/{}
In the same vein as be18b7dc2¹.
Before:
error: syntax error, expecting ';'
After:
error: syntax error, expecting ';' to end binding
[1]: be18b7dc25
Change-Id: Iffbcb113d2b892a50c646c9875e970376a6a6964
This commit is contained in:
@@ -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<binding, seps, must<one<';'>>>
|
||||
seq<binding, seps, must<d::t::binding>>
|
||||
>,
|
||||
seps
|
||||
>
|
||||
@@ -447,9 +448,9 @@ struct bindings : opt<
|
||||
struct repl_binding : binding {};
|
||||
|
||||
struct repl_bindings : seq<
|
||||
list<repl_binding, one<';'>, t::sep>,
|
||||
list<repl_binding, d::t::binding, t::sep>,
|
||||
/* Optional semicolon at the end for convenience */
|
||||
opt<seps, one<';'>>
|
||||
opt<seps, d::t::binding>
|
||||
> {};
|
||||
|
||||
struct op {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
let
|
||||
a = ""
|
||||
in a
|
||||
@@ -0,0 +1,6 @@
|
||||
error: syntax error, expecting ';' to end binding
|
||||
at /pwd/in.nix:3:1:
|
||||
2| a = ""
|
||||
3| in a
|
||||
| ^
|
||||
4|
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user