less / less/less.js

Global Variables with a literal "." in the value causes the variable to be undefined

Open
#3,767 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

To reproduce:
This can be reproduced using the CLI or the programmatic API. Assuming that LESS is already installed, it is most straightforward to reproduce using the CLI:

echo "body { color: @buildVersion; }" | npx lessc --global-var="buildVersion=a.hello" -

On the other hand, removing the literal period allows this to work:

echo "body { color: @buildVersion; }" | npx lessc --global-var="buildVersion=hello" -

LESS Code:

body { color: @buildVersion; }

Current behavior:
The LESS compiler throws an error that the global variable is undefined.

Expected behavior:
The LESS compiler should not throw an error and the global variable should be defined.

Environment information:

  • less version: 3.5.0 - 4.1.3 (current)
  • nodejs version: 16.13.2
  • operating system: Windows

Appears to have been introduced in 3.5.0. Version 3.0.4 appears to be working fine.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided npx lessc command with and without the literal period, then compare how the --global-var value is handled through the CLI and programmatic API. Look for the global-variable parsing or resolution path and add a regression check; done means the a.hello value compiles without an undefined-variable error while the existing hello case still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.