Skip to content

[Compilation] Improve sanization and optimization of options #17

@SirLynix

Description

@SirLynix

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions