less.js icon indicating copy to clipboard operation
less.js copied to clipboard

less parse about inconsistent operation performance

Open zhusjfaker opened this issue 3 years ago • 1 comments

To reproduce:


// parse ok

@c:20px + 20px * 2px;

.d {
    font-size: @c;
}

// parse ok

@c:20px + (20px * 2px);

.d {
    font-size: @c;
}

// parse fail

@c:20px + 20px / 2px;

.d {
    font-size: @c;
}

// parse ok

@c:20px + (20px / 2px);

.d {
    font-size: @c;
}

Current behavior:

less.js the operation of variables is inconsistent in multiplication and division

Expected behavior:

consistent behavior

Environment information:

  • less version: 3.13.0
  • nodejs version: 16.13
  • operating system: darwin

please do not forcibly close issue

zhusjfaker avatar Feb 18 '22 06:02 zhusjfaker

I'm trying to fix this issue, there have been many discussions about math rules in less. This is an issue of historical discussions https://github.com/less/less.js/issues/1880 I found in the documentation the new operation description in less 4 https://github.com/less/less-docs/blob/master/content/usage/less-options.md 屏幕截图 2022-03-30 204547 Another issue also verified my view https://github.com/less/less.js/issues/3586 My understanding is that, we should throw error in there 7 situations.

// parse fail
@c:20px + 20px / 2px; 

// parse fail
@c:20px - 20px / 2px; 

// parse fail
@c:20px / 20px / 2px; 

// parse fail
@c:20px * 20px / 2px; 

// parse fail
@c:20px / 20px + 2px; 

// parse fail
@c:20px /20px - 2px; 

// parse fail
@c:20px / 20px * 2px; 

I'm not sure my understanding is correct. I need your advice to modify pr. @matthew-dean @iChenLei

lumburr avatar Mar 30 '22 12:03 lumburr

Yes, the failures are expected in the current Less math mode. See: https://github.com/less/less-docs/blob/master/content/usage/less-options.md#math

matthew-dean avatar Apr 01 '23 16:04 matthew-dean