From 2b6a926bb60ea652997401d37fc11f5a29f5b20b Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Thu, 18 Jul 2024 21:05:04 +0200 Subject: [PATCH] fix OLS #52 --- core/odin/parser/parser.odin | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index dec892f84..e164c778b 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -2179,22 +2179,25 @@ parse_inlining_operand :: proc(p: ^Parser, lhs: bool, tok: tokenizer.Token) -> ^ } } - #partial switch e in ast.strip_or_return_expr(expr).derived_expr { - case ^ast.Proc_Lit: - if e.inlining != .None && e.inlining != pi { - error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure literal") + if expr != nil { + #partial switch e in ast.strip_or_return_expr(expr).derived_expr { + case ^ast.Proc_Lit: + if e.inlining != .None && e.inlining != pi { + error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure literal") + } + e.inlining = pi + return expr + case ^ast.Call_Expr: + if e.inlining != .None && e.inlining != pi { + error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure call") + } + e.inlining = pi + return expr } - e.inlining = pi - case ^ast.Call_Expr: - if e.inlining != .None && e.inlining != pi { - error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure call") - } - e.inlining = pi - case: - error(p, tok.pos, "'%s' must be followed by a procedure literal or call", tok.text) - return ast.new(ast.Bad_Expr, tok.pos, expr) } - return expr + + error(p, tok.pos, "'%s' must be followed by a procedure literal or call", tok.text) + return ast.new(ast.Bad_Expr, tok.pos, expr) } parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {