-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
improve error message for unable to evaluate constant expression in inline while #1732
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
Comments
You need to make That said I think we can improve the error message. |
Zig's C++ codebase calls Example: Last week, in usercode, I mistakenly wrote
The |
Ran into this today. It's very confusing.
will say:
And my first thought is: "What?! Why? If the expression is constant, then why can't you evaluate it? Should be easy, right?" Better would be something like: "Runtime variable used in comptime expression." |
I ran into this error message with this bit of code: const value: f32 = 1. + get_value();
_ = std.math.clamp(value, 0.0, 255.0); Here the problem is that |
I believe that the error message actually means "expression cannot be evaluated at comptime" or something to that effect. The wording of the message says something completely different (and wrong). |
Now results in:
Tested in:
|
The following code works as I would expect.
However changing line 6 to
inline while (i <= upper) : (i += 1) {
produces the following error:2 thoughts:
inline while
vswhile
or whatever the underlying issue is would be greatly appreciated.The text was updated successfully, but these errors were encountered: