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

Better error message for attempt to subtract with overflow #445

Open
gabizon103 opened this issue May 31, 2024 · 1 comment
Open

Better error message for attempt to subtract with overflow #445

gabizon103 opened this issue May 31, 2024 · 1 comment
Labels
C: Internals Component: Compiler internals

Comments

@gabizon103
Copy link
Collaborator

gabizon103 commented May 31, 2024

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.

@gabizon103 gabizon103 added the C: Internals Component: Compiler internals label May 31, 2024
@gabizon103
Copy link
Collaborator Author

Another one of these:

thread 'main' panicked at crates/utils/src/position.rs:152:9:
unknown position cannot be converted into label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Internals Component: Compiler internals
Projects
None yet
Development

No branches or pull requests

1 participant