Skip to content

test: regression test for @container mixin parameter variable resolution#4420

Open
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-mixins-with-parameters
Open

test: regression test for @container mixin parameter variable resolution#4420
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-mixins-with-parameters

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Using mixin parameters as both the container name and query condition in @container at-rules failed with "variable @bp is undefined" in Less 4.4.2–4.5.1.

@width: 125px;

.mixin(@container-name; @bp) {
  @container @container-name (width < @bp) {
    display: none;
  }
}

.foo {
  .mixin(name, @width);  // Previously: "variable @bp is undefined"
  color: red;
}

The underlying bugs were fixed in v4.6.0 via three separate commits:

  • QueryInParens.eval rewrite — old code mutated node state in-place and conditionally restored from a deep copy only when variable declarations were found in frames; rewritten to always return a fresh evaluated node, eliminating the mutation/context-sensitivity
  • _evaluated flag on Container — prevents double evaluation when the container node is re-encountered in the parent ruleset's eval loop after being returned from the mixin
  • functionRegistry null guardcontext.frames[0].functionRegistry.inherit() now guarded against undefined, matching the defensive pattern in mixin-definition.js

This PR adds the missing regression test covering variable container names combined with variable query conditions inside mixin calls, including multiple calls with differing parameters.

Original prompt

This section details on the original issue you should resolve

<issue_title>Mixins with parameters do not work properly</issue_title>
<issue_description>To reproduce:

Try this code in Playground:

@width: 125px;

.mixin(@container-name; @bp) {
  @container @container-name (width < @bp) {
    display: none;
  }
}

.foo {
  .mixin(name, @width);
  color: red;
}

Current behavior:

Does not compile with an error

variable @bp is undefined

Expected behavior:

Compiles to

.foo {
  color: red;
}
@container name (width < 125px) {
  .foo {
    display: none;
  }
}

Environment information:

  • less version: 4.4.2
    </issue_description>

<agent_instructions>Can you make a branch / PR with a fix for this? Probably something in @container parsing and evaluation?</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@matthew-dean I'm not sure the Dosubot is correct -- this is probably a bug specifically in the `@container` at-rule parsing & evaluation (or general at-rule parsing & evaluation).

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 10, 2026 23:51
Co-authored-by: matthew-dean <414752+matthew-dean@users.noreply.github.com>
Co-authored-by: matthew-dean <414752+matthew-dean@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix mixins with parameters not compiling correctly test: regression test for @container mixin parameter variable resolution Mar 11, 2026
@matthew-dean matthew-dean marked this pull request as ready for review March 12, 2026 20:07
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 12, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 61d62770-5dd6-468b-a077-1432a1d1526a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/fix-mixins-with-parameters
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mixins with parameters do not work properly

2 participants