Repository navigation
fix #2868: preserve detached ruleset definition scope - #4491
ShirayukiRin wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
|
@coderabbitai Any concerns / possible unexpected behaviors that this change could cause? That maybe is not covered by tests? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Changed files and patch ---'
git diff --find-renames origin/master...HEAD -- \
packages/less/lib/less/tree/declaration.js \
packages/test-data/tests-unit/detached-rulesets/detached-rulesets.less \
packages/test-data/tests-unit/detached-rulesets/detached-rulesets.css || true
printf '%s\n' '--- Source outlines ---'
ast-grep outline packages/less/lib/less/tree/declaration.js --items all || true
fd -t f -a 'detached-ruleset|detached-rulesets|ruleset' packages/less/lib/less | sort
printf '%s\n' '--- evalFirst references with context ---'
rg -n -C 5 '\bevalFirst\b' packages/less/lib/less packages/test-data/tests-unit
printf '%s\n' '--- DetachedRuleset references with context ---'
rg -n -C 5 '\bDetachedRuleset\b' packages/less/lib/less packages/test-data/tests-unit
printf '%s\n' '--- Detached-ruleset fixture ---'
cat -n packages/test-data/tests-unit/detached-rulesets/detached-rulesets.less
printf '%s\n' '--- Expected CSS ---'
cat -n packages/test-data/tests-unit/detached-rulesets/detached-rulesets.css
printf '%s\n' '--- Declaration implementation ---'
cat -n packages/less/lib/less/tree/declaration.jsLength of output: 35775 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Parser declaration construction ---'
sed -n '1460,1560p' packages/less/lib/less/parser/parser.js
sed -n '1690,1760p' packages/less/lib/less/parser/parser.js
printf '%s\n' '--- Ruleset evaluation order ---'
sed -n '160,270p' packages/less/lib/less/tree/ruleset.js
printf '%s\n' '--- Variable lookup implementation ---'
ast-grep outline packages/less/lib/less/tree/variable.js --items all || true
cat -n packages/less/lib/less/tree/variable.js
printf '%s\n' '--- Mixin lookup and detached-ruleset call paths ---'
ast-grep outline packages/less/lib/less/tree/mixin-call.js --items all || true
rg -n -C 4 '\bfind\b|\bframes\b|callEval' packages/less/lib/less/tree/mixin-call.js packages/less/lib/less/tree/mixin-definition.js
printf '%s\n' '--- Relevant test fixtures ---'
rg -n -i -C 3 'definition scope|caller.*scope|scope.*caller|detached.*mixin|@.*:\s*\{' \
packages/test-data/tests-unit \
-g '*.less' -g '*.css' | head -n 500
printf '%s\n' '--- Linked issue ---'
gh issue view 2868 --repo less/less.js --commentsLength of output: 41690
I see two useful coverage gaps:
The only expected behavior change is intentional: a declaration whose value has You are interacting with an AI system. |
|
@ShirayukiRin Can you add this coverage before/after?
|
First, thanks for your review. And yeah, sure! I can do that. |
…s in detached rulesets
|
Sorry for the late update. Could you please take another look? Thank you! |
What:
Fix: #2868
Why:
The
DetachedRulesetclass has itsevalFirstproperty set totrue, but when it gets passed to theDeclarationclass in the parser, theDeclarationclass doesn't read and pass down theevalFirstproperty.As a result, the
evalFirstproperty is ignored.Checklist:
I added a unit test according to the contributiing guildelines
Link to the original doc: https://lesscss.org/features/#detached-rulesets-feature-scoping
Summary by CodeRabbit
Bug Fixes
Tests