summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-03-09 09:20:09 -0700
committerOri Bernstein <ori@eigenstate.org>2015-03-09 09:20:09 -0700
commit571feb1d0c9e810665bf28737390d7437628053f (patch)
tree3e5b0fed7527a4dba2c005dfb56471be797e7b82 /parse
parent19d41bb774010f7d81699a249e12ea56faad30d7 (diff)
downloadmc-571feb1d0c9e810665bf28737390d7437628053f.tar.gz
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.
Diffstat (limited to 'parse')
-rw-r--r--parse/infer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/parse/infer.c b/parse/infer.c
index a078c3b..70c5db8 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1618,7 +1618,7 @@ static void infernode(Inferstate *st, Node **np, Type *ret, int *sawret)
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: