degory / ghul

compiler for the ghūl programming language
https://ghul.dev
GNU Affero General Public License v3.0
4 stars 0 forks source link

Allow void values in if expressions #1159

Closed degory closed 7 months ago

degory commented 7 months ago

Allow if expressions to return void values when in a context where void is expected, for example as the body of a function returning void.

print_size(v: int) =>
    if v > 10 then
        write_line("big")
    else
        write_line("small")
    fi;

As the result is not actually consumed, we can allow void if expressions with no else

print_size_if_big(v: int) =>
    if v > 10 then
        write_line("big")
    fi;