Page MenuHomePhabricator

less.php ParseError with variable interpolation after ':' in selector
Closed, ResolvedPublic

Description

Imported from https://github.com/wikimedia/less.php/issues/52.

@plumbojumbo@github.com wrote on 30 Nov 2020:

This succeeds:

(new Less_Parser())->parse('@position: after; .@{position} {}');

This, however, fails:

(new Less_Parser())->parse('@position: after; &:@{position} {}');
ParseError: Unexpected input in anonymous-file-2.less on line 1, column 14
1| @foo: after; &:@{foo} {}

Both Less.js and lessphp compile it just fine. (cmp.)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I have confirmed that this passes on the specific Less.js version we aim to support (Less.js 2.5.3), e.g. via fiddle.

@position: after;

.foo {
    &:@{position} {
        color: green;
    }
}

Which Less.js 2.5.3 compiles to:

.foo:after {
  color: green;
}
Krinkle triaged this task as Medium priority.Jan 17 2023, 11:46 AM

Change 880942 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/libs/less.php@master] Less_Marser: Misc clean up for readability and parity with less.js

https://gerrit.wikimedia.org/r/880942

Change 880943 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/libs/less.php@master] Fix ParseError when interpolating variable after colon in selector

https://gerrit.wikimedia.org/r/880943

Change 880942 merged by jenkins-bot:

[mediawiki/libs/less.php@master] Less_Parser: Misc clean up for readability and parity with less.js

https://gerrit.wikimedia.org/r/880942

Change 880943 merged by jenkins-bot:

[mediawiki/libs/less.php@master] Fix ParseError when interpolating variable after colon in selector

https://gerrit.wikimedia.org/r/880943