diff options
Diffstat (limited to 'src/parse.cff')
| -rw-r--r-- | src/parse.cff | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/parse.cff b/src/parse.cff index f2bbb41..e32b758 100644 --- a/src/parse.cff +++ b/src/parse.cff @@ -142,7 +142,7 @@ fn eatspaces(P *Parser) void { // !sorted extern static keyword2str [NUM_KEYWORDS]*const u8 = { "alignof", "and", "as", "break", "case", "const", - "continue", "def", "defmacro", "do", + "continue", "def", "defer", "defmacro", "do", "else", "enum", "extern", "fn", "for", "if", "import", "let", "offsetof", "or", "return", "sizeof", "static", @@ -1510,7 +1510,7 @@ fn pexpostfix(P *Parser) Expr { if args.len >= params.#len and !Fn.variadic { fatal(P, ex.loc, "too many args (%z, expected %z)", args.len, params.#len); } - if args.len < params.#len and !typematchestarg(*param, ex.ty) { + if args.len <= params.#len and !typematchestarg(*param, ex.ty) { err(P, ex.loc, "function call argument type mismatch (%t, expected %t)", ex.ty, *param); } @@ -2444,6 +2444,7 @@ fn parsefn(P *Parser, loc Loc, externp bool, name *const u8) *Decl { } Fn.body = :Some(parseblock(P)); popenv(P); + ir_genfn(P.irctx, Fn); (as(*Arena)P.alloc.a)->destroy(); } } @@ -2752,6 +2753,7 @@ fn parsedecls(P *Parser, loc Loc, yield DeclYielder, yarg *void, toplevel bool) if a.yield { a.yield(decl, a.yarg); } + ir_genstatic(a.P.irctx, decl); } parsevardecl(P, toplevel, externp, #{let?} #t, &varyield, &Arg { P, externp, toplevel, yield, yarg }); return; @@ -2835,6 +2837,7 @@ extern fn parse(P *Parser) [#]Decl { let alloc = Allocator { &aralloc, &Arena:allocf, #null }; let decls Vec<Decl> = {}; P.alloc = (P.tlalloc = &alloc); + P.irctx = mkirctx(P.alloc); P.curenv = mkenv(#null, P.alloc); if primenv == #null { primenv = mkenv(#null, P.alloc); |