diff --git a/src/parser.zig b/src/parser.zig index 9c1ce16..40404dd 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -694,10 +694,20 @@ pub const Parser = struct { } fn parseCall(self: *@This()) !*Expr { + // we parse a primary expression instead of consuming a .Identifier + // since parseCall is connected to the rest of the parser. doing + // identifiers would break the rest of the rules that want primaries. + + // nothing stops us from ensuring expr is a Variable though ;) var expr = try self.parsePrimary(); while (true) { if (self.check(.LeftParen)) { + if (ast.ExprType(expr.*) != .Variable) { + self.doError("cannot call non-variable{}", ast.ExprType(expr.*)); + return Result.CompileError; + } + _ = try self.consumeSingle(.LeftParen); expr = try self.finishCall(expr); } else {