less / less/less.js

Extend syntax inconsistency (was "ParseError: Unrecognised input" on extends)

Open
#2,198 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

If I lint this file by lessc -l file:

.something {
    color: red;
}
body {
    nav {/* a lot more lines */
        ul {
            color: blue;
            /*v1*/
            li:extend(.something);
            /*v2
            li {
                &:extend(.something);
            }*/
        }
        /*v3
        ul li:extend(.something); */
    }
}

I receive a message that isn't even pointing me in the direction of the error:

ParseError: Unrecognised input in file on line 5, column 2:
4 body {
5       [red] nav { /* a lot more lines */ [/red]
6               ul {

There are two issues:

  • The parser accepts only v2 of the the three expressions that appear equivalent to me. My understanding of less is limited so I'm expecting to have overlooked something. I'd appreciate some feedback.
  • In this particular case the ParseError message is not helpful. Guessing from the rarity of misleading messages I've seen so far I'd blame extend. But I should investigate this further.

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 reproducing the example with lessc -l file and compare the parser's handling of the v1, v2, and v3 extend forms. Trace the resulting parse error to determine why it reports the nav line; done means the accepted syntax and any corrected error location are covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.