Skip to content

Commit

Permalink
Fix compiler.classDeclaration
Browse files Browse the repository at this point in the history
  • Loading branch information
zlw committed Nov 14, 2023
1 parent f3ac284 commit 5d99226
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/compiler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ pub const Parser = struct {
}
self.consume(TokenType.RightBrace, "Expect '}' after class body");

self.emitOp(OpCode.op_pop);

if (classCompiler.hasSuperclass) {
self.endScope();
}

self.emitOp(OpCode.op_pop);
}

fn methodDeclaration(self: *Self) void {
Expand Down Expand Up @@ -546,8 +546,7 @@ pub const Parser = struct {
}

fn syntheticToken(self: *Self, text: []const u8) Token {
_ = self;
return Token { .lexeme = text, .line = 0, .token_type = TokenType.Identifier };
return Token { .lexeme = text, .line = self.previous.line, .token_type = TokenType.Identifier };
}

fn super(self: *Self, canAssign: bool) void {
Expand Down

0 comments on commit 5d99226

Please sign in to comment.