diff options
Diffstat (limited to 'src/check.c')
-rw-r--r-- | src/check.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/check.c b/src/check.c index 85e5459..0858c67 100644 --- a/src/check.c +++ b/src/check.c @@ -216,6 +216,12 @@ static int analyze_formal_def(struct state *state, struct scope *scope, if (analyze_type(scope, n)) return -1; + if (!concrete_type(n->t)) { + semantic_error(scope, n, "illegal type for formal parameter: %s", + type_str(n->t)); + return -1; + } + if (scope_add_formal(scope, n)) return -1; @@ -653,7 +659,7 @@ static int analyze_proc_call(struct state *state, struct scope *scope, foreach_node(a, args) { if (a->t != formal->t) { - semantic_error(scope, c, "expected %s, got %s", + semantic_error(scope, a, "expected %s, got %s", type_str(formal->t), type_str(a->t)); return -1; } @@ -723,9 +729,9 @@ static int analyze_until(struct state *state, struct scope *scope, if (analyze(state, until_scope, cond)) return -1; - if (cond->t != TYPE_BOOL) { - semantic_error(scope, cond, "expected %s, got %s", - type_str(TYPE_BOOL), type_str(cond->t)); + if (cond->t != TYPE_BOOL && cond->t != TYPE_INT) { + semantic_error(scope, cond, "expected truthy type, got %s", + type_str(cond->t)); return -1; } @@ -749,9 +755,9 @@ static int analyze_unless(struct state *state, struct scope *scope, if (analyze(state, scope, cond)) return -1; - if (cond->t != TYPE_BOOL) { - semantic_error(scope, cond, "expected %s, got %s", - type_str(TYPE_BOOL), type_str(cond->t)); + if (cond->t != TYPE_BOOL && cond->t != TYPE_INT) { + semantic_error(scope, cond, "expected truthy type, got %s", + type_str(cond->t)); return -1; } |