about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mpick.c6
-rwxr-xr-xt/2000-mpick.t5
2 files changed, 7 insertions, 4 deletions
diff --git a/mpick.c b/mpick.c
index d72301c..5fcb308 100644
--- a/mpick.c
+++ b/mpick.c
@@ -423,6 +423,7 @@ parse_binding()
 	struct binding *b;
 	char *s;
 	size_t l = 0;
+	struct pos savepos = { pos, line, linenr };
 
 	if (parse_ident(&s, &l)) {
 		for (sc = scopeq; sc; sc = sc->prev) {
@@ -436,9 +437,8 @@ parse_binding()
 			}
 		}
 	}
-	// back to the start of the ident if there was one
-	pos = pos-l;
-	parse_error_at(NULL, "unknown expression");
+
+	parse_error_at(&savepos, "unknown expression");
 	return 0;
 }
 
diff --git a/t/2000-mpick.t b/t/2000-mpick.t
index 3cff87e..0b1296c 100755
--- a/t/2000-mpick.t
+++ b/t/2000-mpick.t
@@ -1,7 +1,7 @@
 #!/bin/sh -e
 cd ${0%/*}
 . ./lib.sh
-plan 27
+plan 28
 
 rm -rf test.dir
 mkdir test.dir
@@ -82,6 +82,9 @@ check_same 'create file' 'mlist inbox | mpick -t "print >\"foo\" && skip" && cat
 check_same 'overwrite file' 'mlist inbox | mpick -t "print >\"foo\" && skip" && cat foo' 'mlist inbox'
 check_same 'append file' 'mlist inbox | mpick -t "print >>\"foo\" && skip" && cat foo' 'mlist inbox && mlist inbox'
 
+check_same 'unknown ident' 'mlist inbox | mpick -t "let x = x in x" 2>&1' \
+	"echo \"mpick: parse error: argv:1:9: unknown expression at 'x in x'\""
+
 cat <<! >expr
 let foo = from.addr == "peter@example.org"
 let bar = from.disp == "Peter Example"