odin-lang / Odin

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

Procedure assignment with tenary when #3863

Closed JesseRMeyer closed 11 hours ago

JesseRMeyer commented 3 days ago

As discussed in Discord. Feature request for this to work.

empty_proc :: #force_inline proc(..any) {}
end_mark :: empty_proc when !TRACY_ENABLE else proc(ctx: zone_context) {
  zone_end(ctx)
}

emits the compiler error: Error: 'empty_proc when !TRACY_ENABLE else proc(ctx: zone_context) {...}' is not a compile-time known constant

Which is currently not considered a bug but could be made to work. The current behavior is unintuitive and feels needlessly restrictive.

Feoramund commented 3 days ago

Wouldn't @(disabled=TRACY_DISABLE) suit your needs here?

JesseRMeyer commented 3 days ago

Sometimes it does but disabled still compiles & checks the code. Though more important imo is how procs are handled in when statements more broadly.

laytan commented 2 days ago

This should work now: https://github.com/odin-lang/Odin/commit/657bc88535eb3b160d86fed5f5e5d0d6ea67c78c