-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Evaluating @arguments #2436
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
Comments
I added "Bug" label at first, but I'm quite confused now. Notice that it not so different from the second example in Lazy Loading. Also it's not limited to only
Just in case I also tested earlier versions (down to 1.4.2) and it's always been like this. P.S.
However if you add those undefined variables there they yet again trigger the deepest evaluation back (so in the previous example it actually complains about unused variables :)
|
Yes it seems to be consistent with lazy loading but still weird... |
@seven-phases-max Like you said it's not limited to |
Since I mentioned this issue in #2433 (comment), I feel like I need to provide an alternative answer now. Regardless of how we'll decide to treat that (change or not) the root of the problem in the example is of course the use of the caller variable in the called mixin, in Less it's a perfect way to shoot yourself in the foot. Such cases always should be taken with care and avoided when possible (the problem is that there're too many directly contradictory scope handling expectations and already implemented rules so it will always have "issues"). So yes, even if we decide to change it for
|
More confirmation for what has been on my mind for some time now: Of late there have been far too many instances of people shooting themselves in the foot or the compiler containing actual bugs, all in major part due to trying to cope with the quirks and exceptions in these rules. Perhaps it's time to make work of missing crucial features such as lambdas and function return values and just switch to passing by parameter, closure scope or return value only: neat, nice and above all predictable. As for a migration path and backwards compatibility: we already have |
Well, strictly speaking, Less scoping rules are uniform and strict. Even the most famous #1316 (that applies here as well) is not caused by actually different (or some "clever") scoping rules but is only a result of different "use" and "meaning" of plain rulesets and parametric mixins (I explained it in details here).
Ready to make a PR for all this? ;) OK, just killing. But in this context I'd like to remind that initially Less is meant to be not programming language at all (in classical sense of this term, just like CSS isn't). And while recently it's got some of such functionality, expecting all these not-even-considered-initially features (callbacks, lamdas, functions, OOP classes) to appear instantly and fit like a charm out-of-the-box into existing facilities is rather strange. P.S.
There's actually, you'll wonder to find out how few Less users use mixins and are aware of scope (or care of these things at all, for 90% of users Less code is just "bunch of global variables + nesting" that's it). So implementing those different (from current) scoping rules enabled by some option (which is basically equal to having two different languages in the same compiler) sounds like a total overkill (that thing will be simply unmaintainable). |
Well; lambdas and real mixin return values are general additions that don't change existing behavior. The scoping rules are the only real change: as far as I've been able to tell, mostly everything is already using normal closure scope, but pulls in stuff from other scopes in addition to that. A
Sorry; kind of busy with |
Yes, sure, lambdas and mixin return values won't be affected by and/or won't change scoping rules, hence
Just turning caller scope off? OK, makes sense then... to solve this one (Sorry, I was thinking you also mean other scope issues). |
After some thinking I'm about closing this (feel free to reopen). And while it would seem to be natural to make an exception for For the particular example of the initial post this means it should not rely on the special .mixin(@parameters...) {
@x: @parameters;
.output(@whatever) {
x: @x;
}
.output(unexpected);
}
.test {
.mixin(expected);
} |
Closing as expected behaviour. |
Hi guys.
For the following Less code:
I would expect the rendered CSS to be like this:
But actually it is:
I know that Less lazy loads variables but this still seems weird to me. Shouldn't things like
@arguments
and@rest
be evaluated before it goes into deeper scope?The text was updated successfully, but these errors were encountered: