nooc

nooc programming language compiler
git clone git://git.nihaljere.xyz/nooc
Log | Files | Refs | LICENSE

commit d496fab1ba3f530197e29ec10e285344c5e3538b
parent 32f55ca8fa60097ffaba66273a4fd64c9299b676
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Mon, 13 Dec 2021 15:58:02 -0600

decl: number of parameters must match in proc type and proc expression

Diffstat:
Mmain.c | 3+++
Atest/mismatch_proc_type_expr_param_len.fail.nooc | 8++++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/main.c b/main.c @@ -182,6 +182,9 @@ typecheck(struct block items) expr = &exprs.data[decl->val]; if (expr->class != C_PROC) error(decl->start->line, decl->start->col, "expected proc expression for proc declaration"); + + if (expr->d.proc.params.len != type->d.typelist.len) + error(decl->start->line, decl->start->col, "procedure expression takes %u parameters, but declaration has type which takes %u", expr->d.proc.params.len, type->d.typelist.len); break; default: error(decl->start->line, decl->start->col, "unknown decl type"); diff --git a/test/mismatch_proc_type_expr_param_len.fail.nooc b/test/mismatch_proc_type_expr_param_len.fail.nooc @@ -0,0 +1,8 @@ +let exit proc = proc(code i64) { + syscall(60, code) + return +} + +let main proc = proc { + exit(0) +}