Fix parsing #force_inline call expression with or_return

This commit is contained in:
Fabian Sperber
2023-09-05 22:35:30 +02:00
parent d60c619c44
commit bbf9678756
2 changed files with 22 additions and 1 deletions
+21
View File
@@ -553,6 +553,27 @@ unparen_expr :: proc(expr: ^Expr) -> (val: ^Expr) {
return
}
strip_or_return_expr :: proc(expr: ^Expr) -> (val: ^Expr) {
val = expr
if expr == nil {
return
}
for {
inner: ^Expr
#partial switch e in val.derived {
case ^Or_Return_Expr:
inner = e.expr
case ^Paren_Expr:
inner = e.expr
}
if inner == nil {
break
}
val = inner
}
return
}
Field_Flags :: distinct bit_set[Field_Flag]
Field_Flag :: enum {
+1 -1
View File
@@ -2153,7 +2153,7 @@ parse_inlining_operand :: proc(p: ^Parser, lhs: bool, tok: tokenizer.Token) -> ^
}
}
#partial switch e in ast.unparen_expr(expr).derived_expr {
#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")