ref: 6476ae94e37b0a07578973bfc1615088dd62f0bf
parent: 90c51e292f87d9df082f074f1b90d38d0af3eb10
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Mar 9 05:20:09 EDT 2015
Give better context for errors in match statements. In the past, we gave bad context for match statements type errors, giving the error on the match line. Eg: var x : byte var y : byte[:] match y | ...: | foo: x = 4oo ;; would error on 'match' and not on 'foo'. This simple change solves that prolem by passing the pattern value as context.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1618,7 +1618,7 @@
fatal(n, "Can't match against a void type near %s", ctxstr(st, n->matchstmt.val));
for (i = 0; i < n->matchstmt.nmatches; i++) {
infernode(st, &n->matchstmt.matches[i], ret, sawret);
- unify(st, n, type(st, n->matchstmt.val), type(st, n->matchstmt.matches[i]->match.pat));
+ unify(st, n->matchstmt.matches[i]->match.pat, type(st, n->matchstmt.val), type(st, n->matchstmt.matches[i]->match.pat));
}
break;
case Nmatch: