SomMeri / less4j

Less language is an extension of css and less4j compiles it into regular css. Less adds several dynamic features into css: variables, expressions, nested rules, and so on. Less was designed to be compatible with css and any correct css file is also correct less file.
146 stars 47 forks source link

Bug with mixins using (...) and (@arguments) special variable #343

Open twhoff opened 8 years ago

twhoff commented 8 years ago

Different behaviour in LESS and LESS4J, see following example:

CODE

.test {
    .test-base(arg1; arg2; arg3);
}

.test-base(...) {
    .test-1(@arguments);
    .test-2(@arguments);
    .test-3(@arguments);
    .test-4(@arguments);
}

// Extract from @arguments passed in as ... binder
.test-1(...) {
    len-check1: length(@arguments);
    test-extract1: extract(@arguments, 1);
}

// Extract from @arguments passed in with same name
.test-2(@arguments) {
    len-check2: length(@arguments);
    test-extract2: extract(@arguments, 1);
}

// Extract from @arguments passed in as @args
.test-3(@args) {
    len-check3: length(@args);
    test-extract3: extract(@args, 1);
}

// Extract from @arguments in parent scope
.test-4(@random) {
    len-check4: length(@arguments);
    test-extract4: extract(@arguments, 1);
}

OUTPUT LESS (correct)

.test {
  len-check1: 3;
  test-extract1: arg1;
  len-check2: 3;
  test-extract2: arg1;
  len-check3: 3;
  test-extract3: arg1;
  len-check4: 3;
  test-extract4: arg1;
}

**OUTPUT LESS4J (incorrect)***

.test {
  len-check1: 1;
  test-extract1: arg1 arg2 arg3;
  len-check2: 3;
  test-extract2: arg1;
  len-check3: 3;
  test-extract3: arg1;
  len-check4: 1;
  test-extract4: arg1 arg2 arg3;
}

Test 1 and 4 fail in LESS4J.

SomMeri commented 8 years ago

Thank you, I will have a look at this after #342.