-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 shouldn't evaluate its not returned arg
#3371
Comments
Did it work before? (Now when you mentioned this I have some doubts... Even if it was me putting that example there. The problem is most likely not |
I does not know if this has work before. I expect that the person which have write the documentation has it test. In general it is easier to run the code and copy the result as to write the expected result manually. But if you think this can not work and it is a problem in the documentation then forward this to the documentation team. I have use this sample only as test code for JLessC which can evaluate it without an error. |
I have use this sample only as test code for Just out of curiosity, what is x {
a: if(true, darken(red, 10%), 123);
@x: red;
b: if(true, darken(@x, 10%), 123);
@y: darken(@x, 10%);
c: if(true, @y, 123);
} ? |
Do you see a problem with it? |
No, that's what I would expect (I was just wondering how/if it also evaluates args before the function itself). In summary (as far as I understand it) I'm afraid it was just initially not-working example (my bad). |
if
function shouldn't evaluate its not returned arg
What's the issue here? The sample should fail because |
Regarding the arguments being evaluated regardless of being "needed", that's essentially how all Less functions work AFAIK. Less doesn't know what the function will do with the data. So, to me, this is 100% expected. |
Yes, it is expected by the way functions are implemented. But it spoils the very idea of the function if it's not following the mainstream languages logic of not evaluating the false path. |
From a consistency point of view this can be reworded as:
(basically the same thing). |
Hmm....yes that's maybe possible, but I'm not sure how this could be done in a generic way.... unless.... functions had an API / flag for discarding errors in eval'd arguments? Maybe functions would receive an error array (mapping to argument position) that they could decide to discard? Although.... honestly.... isn't it just simpler to not pass un-evaluatable expressions to functions in the first place? Seems like a lot of feature re-work for something that could be solved via refactoring. |
Well, yes. But an "un-evaluatable expression" might be the very reason the color: darken(if(iscolor(@some), @some, lighten(gray, 10%)), 10%); But the "naturality" is lost. Either I can't see anything wrong in... hmm... to wait and see how soon the issue raises on its own. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
FYI - I've done some initial work in 4.x to support this feature. |
The sample:
produce with version 3.9.0 the follow error:
it look like that the THEN part is evaluate if the ELSE part should be used.
The text was updated successfully, but these errors were encountered: