Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compilation] Improve sanization and optimization of options #17

Open
SirLynix opened this issue Jun 21, 2022 · 0 comments
Open

[Compilation] Improve sanization and optimization of options #17

SirLynix opened this issue Jun 21, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@SirLynix
Copy link
Contributor

Currently, options are treated like unknown values, or even unknown types.

However, it would be pretty simple to handle cases where the value is known and validation / optimization can be done.

option enabled: bool;

fn main()
{
    const if (enabled)
    {
        // enabled is known to be true here
    }
}
option value: i32;

fn main() -> i32
{
    const if (value == 42)
        return value + 5; //< optimized by return 47
    else
        return value; //< kept as is
}

Theses examples may seem a bit silly, but will become more interesting once we have function inlining

@SirLynix SirLynix added the enhancement New feature or request label Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant