mpick: improve unknown binding error and add test case

pull/174/head
Duncan Overbruck 4 years ago committed by Leah Neukirchen
parent 0645634733
commit b79e38b686

@ -423,6 +423,7 @@ parse_binding()
struct binding *b; struct binding *b;
char *s; char *s;
size_t l = 0; size_t l = 0;
struct pos savepos = { pos, line, linenr };
if (parse_ident(&s, &l)) { if (parse_ident(&s, &l)) {
for (sc = scopeq; sc; sc = sc->prev) { 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(&savepos, "unknown expression");
parse_error_at(NULL, "unknown expression");
return 0; return 0;
} }

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
cd ${0%/*} cd ${0%/*}
. ./lib.sh . ./lib.sh
plan 27 plan 28
rm -rf test.dir rm -rf test.dir
mkdir 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 '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 '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 cat <<! >expr
let foo = from.addr == "peter@example.org" let foo = from.addr == "peter@example.org"
let bar = from.disp == "Peter Example" let bar = from.disp == "Peter Example"

Loading…
Cancel
Save