summaryrefslogtreecommitdiffstats
path: root/src/parser_bison.y
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2018-12-01 12:06:46 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2018-12-01 12:09:24 +0100
commitbe79e9c3467b324216688047c81315f0d3e51d24 (patch)
tree97616474615a0f1a0d44c42884f5e360ea8abd9d /src/parser_bison.y
parentfa145fdf73d663eb69751800911cdd2853689dee (diff)
src: introduce simple hints on incorrect identifier
# cat test.nft define test = "1.2.3.4" table ip x { chain y { ip saddr $text } } # nft -f test.nft test.nft:5:13-16: Error: unknown identifier 'text'; did you mean identifier ‘test’? ip saddr $text ^^^^ Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r--src/parser_bison.y12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y
index dfe30683..e73e1ecd 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -3078,8 +3078,16 @@ variable_expr : '$' identifier
sym = symbol_get(scope, $2);
if (!sym) {
- erec_queue(error(&@2, "unknown identifier '%s'", $2),
- state->msgs);
+ sym = symbol_lookup_fuzzy(scope, $2);
+ if (sym) {
+ erec_queue(error(&@2, "unknown identifier '%s'; "
+ "did you mean identifier ‘%s’?",
+ $2, sym->identifier),
+ state->msgs);
+ } else {
+ erec_queue(error(&@2, "unknown identifier '%s'", $2),
+ state->msgs);
+ }
xfree($2);
YYERROR;
}