parser: ensure calls only happen to Variables
This commit is contained in:
parent
5ba807d93f
commit
8f44cbea23
1 changed files with 10 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue