Skip to content

Cannot read property 'clone' of undefined. #3586

Closed

Description

@laino
@c: 1 + 1 / 1;
SyntaxError: Cannot read property 'clone' of undefined in /home/lain/test.less on line 1, column 1:

Activity

  1. matthew-dean commented on Jan 7, 2021

    @matthew-dean
    Member

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

  2. laino commented on Jan 10, 2021

    @laino
    Author

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

  3. laino commented on Jan 10, 2021

    @laino
    Author
  4. laino commented on Jan 10, 2021

    @laino
    Author

    Actually the * 4 isn't even necessary.

    Just this is enough:

    @c: 1 + 1 / 1;
  5. RealDolos commented on Jan 10, 2021

    @RealDolos

    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

  6. matthew-dean commented on Jan 13, 2021

    @matthew-dean
    Member

    This is a bug that just got introduced?

  7. laino commented on Jan 13, 2021

    @laino
    Author

    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.

  8. added a commit that references this issue on Jan 13, 2021
    2b69eea
  9. matthew-dean commented on Jan 13, 2021

    @matthew-dean
    Member

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

  10. RealDolos commented on Jan 15, 2021

    @RealDolos

    Less should be throwing 'Operation on an invalid type'

    Why?

  11. matthew-dean commented on Jan 15, 2021

    @matthew-dean
    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.

  12. matthew-dean commented on Jan 15, 2021

    @matthew-dean
    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.

  13. RealDolos commented on Jan 15, 2021

    @RealDolos

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

  14. matthew-dean commented on Jan 15, 2021

    @matthew-dean
    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.

  15. added a commit that references this issue on Mar 16, 2024
    f727b26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions