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

Precedence bug with if expressions #170

Open
rewbs opened this issue Jul 10, 2023 · 1 comment
Open

Precedence bug with if expressions #170

rewbs opened this issue Jul 10, 2023 · 1 comment

Comments

@rewbs
Copy link
Owner

rewbs commented Jul 10, 2023

if true 10 else 5/2 evaluates as (if true 10 else 5)/2, instead of if true 10 else (5/2) .

@sashaagafonoff
Copy link

yes! I finally worked this out with an issue i've been having for a while with conditional statements:

the offending statement:
if (f-info_match_prev("scene")<4) 0.9 else 0.55 - pulse(p=3b,a=0.075,pw=2)
image

the fix:
if (f-info_match_prev("scene")<4) 0.9 else (0.55 - pulse(p=3b,a=0.075,pw=2))
image

Easy workaround (enclose your blocks in parentheses).

I think correct behaviour should be that IF you did want a dangling operation at the end (i.e. it applies regardless of truth/falsity), you'd enclose the entire conditional statement in parentheses

e.g.
(if (f-info_match_prev("scene")<4) 0.9 else 0.55) - pulse(p=3b,a=0.075,pw=2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants