Skip to content

Vars storing calculations don't crunch the calculation if the var is used in calc() #3235

@calvinjuarez

Description

@calvinjuarez

This is likely one of the first workarounds people will try when their calc starts working the way it's designed to (ignoring the content of calc()).

Critically, the calculated value of calc(100% - 10px + 30px) (as shown in the v3.5.0-beta output) is NOT the same as the expected and intuitive calculated value of calc(100% - 40px).

test.less

@foo: 10px;

.test {
	@_calculated: (@foo + 30px);
	width: calc(100% - @_calculated);
}

Less 2 Output & Expected

npm i -g less@2 && lessc --strict-math=on test.less ./test.css

.test {
  width: calc(100% - 40px);
}

(see #3221 (comment))

Less 3 Output

npm i -g less@3.5.0-beta && lessc --strict-math=on test.less ./test.css

.test {
  width: calc(100% - 10px + 30px);
}

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