-
Notifications
You must be signed in to change notification settings - Fork 1.1k
inline if error suggests it expects a literal expression #10107
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
this does not work because inline if looks at the static type of the expression - if you make |
perhaps the error is misleading |
Thanks @bishabosha! The message “it needs to be a constant” conveys the correct high-level understanding, adding “(and this expects a literal type)” in parenthesis would be a good addition though. |
Actually, it is a shame to fail on a |
Fix #10107: Improve `inline if` constant condition detraction and reporting
Uh oh!
There was an error while loading. Please reload this page.
Minimized code
Say we make a simple macro that just returns the value
true
.Now if we use that with an inline if statement:
Then when I run that:
The following error happens...
Output
Expectation
I think this should be more intelligent about looking at the AST and detecting if there is a constant value. I even tried making
oneOf
returnLiteral(Constant(true))
but it still did not work.The text was updated successfully, but these errors were encountered: