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

if function evaluates both values despite the condition #3528

Closed
thybzi opened this issue Jul 6, 2020 · 1 comment
Closed

if function evaluates both values despite the condition #3528

thybzi opened this issue Jul 6, 2020 · 1 comment

Comments

@thybzi
Copy link

thybzi commented Jul 6, 2020

Inline conditional function of if(condition, then-value, else-value) has some unexpected behavior.

It tries to evaluate "else-value" even if condition is true and else-value in unneeded. In the same way, "then-value" is evaluated even if condition is false.

That may cause 'Operation on an invalid type' error if condition and value processing depends on value type.

.mymixin(@val) {
    myprop: if(isnumber(@val), @val * 42, @val);
}

a {
    .mymixin(11);    // works perfectly with the result of 462
}

b {
    .mymixin(null);  // causes 'Operation on an invalid type' error
}
@matthew-dean
Copy link
Member

Duplicate of #3371

@matthew-dean matthew-dean marked this as a duplicate of #3371 Jul 7, 2020
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