-
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
Question: should the expression (10 -23) throw syntax error? #1225
Comments
Interesting, it doesn't throw an error if you add a space on both side of the minus sign: test-works {
something: (10 - 23);
} but I confirmed that it does throw an error as you've written it |
yes, it is interpreted as 10 and -23, two values in a space separated list, inside brackets. At the moment the interpretation of brackets happens after parsing in less.js |
.. therefore to fix it we would have to allow |
But in parentheses, doesn't that force attempt of math? |
That is, is there a a valid value that has parentheses as the value (that isn't clearly a media block or a url or a registered LESS function) that wouldn't be math? If not, seems like we can assume math? Or is that a naive assumption? |
yes it attempts maths on maths objects... e.g. the parser parses So, the structure of the two trees is different... Parenthesis -> Value and Parenthesis -> Operation. Either the parser would have to be aware of context and treat it different, or at evaluation time Value would have to say "am I in parenthesis" and convert itself to an operation. Making the parser aware of parenthesis and maths is probably the better solutuion, but a hell of a lot of effort for some less that is confusing and has never been parsed in the past. |
Thank you for all explanations. I was writing blog post about less, run into this and got confused. I will put it into "quirks" chapter and leave it at that. |
Hm, I tried to play around the idea somewhat more. Altrough I do not know how exactly less.js works, this task seems to be even more complicated. Less lazy load variables and lazy evaluates expressions. So, if the solution would keep using lazy rules, the variable
Ratio vs division works the same way, but they are closer to each other then list and expression:
Bleh. |
hrmm list-or-expression is pretty strange. That should probably err...? |
Yes, this will currently err |
I think it is not worth fixing and we should keep it as a syntax error. It looks like it should be valid because in other languages space is not a separator converting it to a list. Reading the mdn documentation on calc https://developer.mozilla.org/en-US/docs/CSS/calc In CSS |
I will close it then. |
Full code:
Error:
It is probably related to this: #952
Tested on 1.4.0-b1 with windows node.js.
The text was updated successfully, but these errors were encountered: