Skip to content

Better error message for attempt to subtract with overflow #445

@gabizon103

Description

@gabizon103

When doing arithmetic on parameters, sometimes the compiler will throw an attempt to subtract with overflow error if you try doing a subtraction that results in a negative number. The error comes from Rust, and happens sometime during the monomorphize pass because parameter values are treated as u64s, so of course they can't be negative. I've had this error pop up a few times because it can be easy to make small mistakes in complicated designs with lots of parameters and parameter arithmetic. If the Filament compiler emitted a proper error message for this that points to the place in the source code where the subtraction happens, it would be easier to debug the design. Off the top of my head, I'm not sure how easy this would be because I'm not sure how much of the source-level mapping information is retained by the time we're in monomorphize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: InternalsComponent: Compiler internals

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions