Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(issue:4331) and keyword treated as function #4332

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

puckowski
Copy link
Contributor

@puckowski puckowski commented Mar 27, 2025

What:

Fix for issue #4331

The and keyword was being treated as a function call starting Less 4.2.1 which introduced selector generation problems.

Why:

The following Less:

@media screen and(max-width:1280px) {
  .form-process-table {
    width: 1200px;
    > div {
      width: 960px;
    }
  }
}

would fail to insert a space after and Keyword like it did in Less 4.2.0. This would cause selector issues in the resulting CSS.

I simultaneously had to add a function definition for size to avoid regressions with container queries when fixing this and issue.

Checklist:

  • Documentation
  • Added/updated unit tests
  • Code complete

Workaround: Ensure a space is present after and in the source Less.

* Fixes issue where and keyword was being treated as a function call.
* Adds definition for size function call.
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 27, 2025
@puckowski
Copy link
Contributor Author

Looks like there are CI issues (may be resolved by #4322):

╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers:              ║
║                                                                         ║
║     pnpm exec playwright install                                        ║
║                                                                         ║
║ <3 Playwright Team                                                      ║
╚═════════════════════════════════════════════════════════════════════════╝

@matthew-dean
Copy link
Member

What change made it be treated like a function?

@puckowski
Copy link
Contributor Author

What change made it be treated like a function?

#4237

The addition of declarationCall which must match functions before keywords (otherwise functions may be identified incorrectly as keywords) caused the regression:

e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup();

#4237 was potentially relying on a weak regex:

validCall = parserInput.$re(/^[\w]+\(/);

though instead of fiddling with a regex in this PR we now check the function registry to sure what we are looking at is a function, otherwise we can later try to parse as keyword.

@matthew-dean
Copy link
Member

@puckowski Seems like I'm getting Playwright errors even after merging the other one 🤔

@puckowski
Copy link
Contributor Author

I pulled latest to get CI changes from #4333 and pushed again. CI is good now. I suspect any old PRs running into this issue will have to pull latest master and repush or rebase.

I suspect old pnpm-lock.yaml files in these older branches is what caused the failures when you reran.

@matthew-dean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants