odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.64k stars 583 forks source link

`#force_*inline` after label segfaults #3727

Closed Feoramund closed 3 months ago

Feoramund commented 3 months ago
package main

main :: proc () {
    label: #force_no_inline for { }
}

parse_force_inlining_operand is expecting parse_unary_expr to return an expression, but it's getting a nullptr. This is preventable with a check after the parse, but I'm not sure if that's the correct spot to do the error-checking.

/tmp/odin/f.odin(4:25) Syntax Error: Expected ';', got for
    label: #force_no_inline for { }
                           ^
/tmp/odin/f.odin(4:26) Syntax Error: force_no_inline must be followed by a procedure literal or call, got for
    label: #force_no_inline for { }
                            ^

This was the output when I put a check after the call to parse_unary_expr. The extra error about the semicolon is what has me wondering if that's not the right way.

This is happening with the latest commit.

gingerBill commented 3 months ago

Well that isn't valid syntax nor semantics to begin with, but it shouldn't crash.