question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`if` function shouldn't evaluate its not returned arg

See original GitHub issue

The sample:

@some: foo;

div {
    margin: if((2 > 1), 0, 3px);
    color:  if((iscolor(@some)), darken(@some, 10%), black);
}

produce with version 3.9.0 the follow error:

RuntimeError: error evaluating function `darken`: color.toHSL is not a function in sample.less on line 5, column 34:
4     margin: if((2 > 1), 0, 3px);
5     color:  if((iscolor(@some)), darken(@some, 10%), black);
6 }

it look like that the THEN part is evaluate if the ELSE part should be used.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
seven-phases-maxcommented, Mar 8, 2019

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). Which in turn means the if implementation should be improved (the way it is now, the false arg is always evaluated - and this is not what we’d expect (ideally)).

0reactions
matthew-deancommented, Nov 13, 2019

FYI - I’ve done some initial work in 4.x to support this feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJS iif arguments are called when shouldn't - Stack Overflow
The problem is that second argument to iif is called even if test function returns false. This throws an error and app crashes...
Read more >
If Statements, Function Returns, Truthy and Falsy - Wes Bos
An if statement will look for the first condition that evaluates to true and then it only runs that block, it will skip...
Read more >
Assessment Unit 7 Flashcards | Quizlet
Study with Quizlet and memorize flashcards containing terms like Parameter, Argument, Return and more.
Read more >
12.5. Returning a value from a function - Runestone Academy
A return statement, once executed, immediately terminates execution of a function, even if it is not the last statement in the function.
Read more >
The Python return Statement: Usage and Best Practices
If you're totally new to Python functions, then you can check out Defining ... The function takes two (non-complex) numbers as arguments and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found