-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
performance, robustness: don't evaluate expressions in conditions unnecessarily #21590
Labels
Feature Request
This issue is made to request a feature.
Comments
spytheman
added
Feature Request
This issue is made to request a feature.
and removed
Bug
This tag is applied to issues which reports bugs.
labels
May 29, 2024
The evaluation order is not defined currently. |
The same problem is demonstrated by this program, that does not need fn f(s string) !int {
if s == '' {
return error('invalid s')
}
return s.len
}
v := ''
x := v != 'xyz' && f(v)! < f('abc')!
dump(x) |
It might work to just cgen the nesting if there is a function expression in a condition. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
A logical AND (&&) with an intentional order of conditional statements could behave the same creating deeper nesting levels.
Reproduction Steps
Result:
version != 'nightly
is checked, still getting the error:Expected Behavior
Same as using a nested conditon:
Result:
Won't error
Current Behavior
Possible Solution
No response
Additional Information/Context
No response
V version
👇
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: