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

Cannot read property 'clone' of undefined. #3586

Closed
laino opened this issue Jan 6, 2021 · 13 comments
Closed

Cannot read property 'clone' of undefined. #3586

laino opened this issue Jan 6, 2021 · 13 comments

Comments

@laino
Copy link

laino commented Jan 6, 2021

@c: 1 + 1 / 1;
SyntaxError: Cannot read property 'clone' of undefined in /home/lain/test.less on line 1, column 1:
@matthew-dean
Copy link
Member

That can't be your only line in the file? Do you have more context?

@laino
Copy link
Author

laino commented Jan 10, 2021

Nope. That's the only line. It takes just that.

@laino
Copy link
Author

laino commented Jan 10, 2021

Here's a video ;)

@laino
Copy link
Author

laino commented Jan 10, 2021

Actually the * 4 isn't even necessary.

Just this is enough:

@c: 1 + 1 / 1;

@RealDolos
Copy link

oopsie whoopsie. other is {operand: "/", ... } still when this code is called:
https://github.com/less/less.js/blob/master/packages/less/src/less/tree/dimension.js#L73

@matthew-dean
Copy link
Member

This is a bug that just got introduced?

@laino
Copy link
Author

laino commented Jan 13, 2021

It's a bug that has existed at least since the 4.0.0 release and is still present in 4.1.0.

It's probably related to the "Parens-division now the default math setting" change.

matthew-dean added a commit to matthew-dean/less.js that referenced this issue Jan 13, 2021
@matthew-dean
Copy link
Member

So it looks like for the above code, Less should be throwing 'Operation on an invalid type'. See: #3589

@RealDolos
Copy link

Less should be throwing 'Operation on an invalid type'

Why?

@matthew-dean
Copy link
Member

@RealDolos Because in parens-division mode (the 4.0 Less default), you're trying to add 1 + a CSS expression 1 / 1. The division won't divide; it will be output as is, so you can't add 1 to it.

@matthew-dean
Copy link
Member

@RealDolos Now, an argument could be made that just the 1 + 1 should add together in that case, but unfortunately that's not the way it's parsed. As it is, division is parsed as a division operation, even if it's not performed, so when it's not performed, it can't be part of other operations, and should throw an error.

@RealDolos
Copy link

Adding 1 + 1 would be surprising behavior I suppose.
Still, "Operation on an invalid type" is a bit of a shit error message

@matthew-dean
Copy link
Member

@RealDolos

Still, "Operation on an invalid type" is a bit of a shit error message

Please be kind. That's the error message thrown on other types if you attempt operations (with like a keyword for example). I only meant it should be throwing a proper error, and that's the current error message for operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment