diff --git a/examples/hello.ry b/examples/hello.ry index f3909eb..26d5cda 100644 --- a/examples/hello.ry +++ b/examples/hello.ry @@ -36,11 +36,14 @@ fn func_refer_param(b: i32) i32 { } fn multwo(num: i32, double_flag: bool) i32 { + if (!double_flag) { + var value = false; + return value; + } + if (double_flag) { - var truthy = true; return num * 2; } else { - var falsey = false; return num; } } diff --git a/src/parsers.zig b/src/parsers.zig index 026d11e..cc4b226 100644 --- a/src/parsers.zig +++ b/src/parsers.zig @@ -1033,8 +1033,9 @@ pub const Parser = struct { fn parseUnary(self: *@This()) anyerror!*Expr { if (self.compareAnyOf(&[_]TokenType{ .Bang, .Minus })) { - var op = self.previous(); - var right = try self.parseUnary(); + var op = self.peek(); + _ = try self.nextToken(); + var right = try self.parseCall(); return try self.mkUnary(try toUnaryOperator(op), right); }