Skip to content

Cannot consume @rest... when not specified #4352

Closed

Description

@Bilge

To reproduce:

.foo(@a, @rest...) {
  .bar(@a, @rest);
}

.bar(@a, @b: false) {}

.foo(@a, true); // works
.foo(@a); // Cannot read properties of undefined (reading 'value')

Current behavior:

Consuming an optional variadic that is not set causes an error.

Expected behavior:

Since (@a, @rest...) supports 1..N arguments, it should be expected that in the 1 case, @rest is unset, and if so, passing @rest should be valid and a no-op instead of an error.

Environment information:

  • less version: 4.4.0
  • nodejs version: v22.12.0
  • operating system: 6.6.87.2-microsoft-standard-WSL2

Activity

  1. puckowski commented on Jul 27, 2025

    @puckowski
    Contributor

    You'd have to define @a at least, but this Less

    .foo(@a, @rest...) {
      .bar(@a, @rest...);
    }
    
    .bar(@a, @b: false) { div { color: @b; } }
    
    @a: 1;
    
    .foo(@a); 

    gives me:

    div {
      color: false;
    }

    in version 4.4.0.

  2. Bilge commented on Jul 27, 2025

    @Bilge
    Author

    Ah, well you changed the calling convention from @rest to @rest..., which is presumably how you're supposed to do it, but this is not documented anywhere.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions