Commit d250d62
Fix
* Initial plan
* Fix: not keyword now works without parentheses in guard conditions
Previously, `boolean(not false)` silently ignored the `not` keyword
while `boolean(not (false))` worked correctly.
The `negatedCondition` parser function consumed the `not` keyword but
only tried `parenthesisCondition`, which requires `(`. With no parens,
it returned undefined with `not` already consumed, causing silent skip.
Fix: fall back to `atomicCondition` when `parenthesisCondition` fails,
allowing both `not false` and `not (false)` to work consistently.
Co-authored-by: matthew-dean <[email protected]>
* Restrict not-without-parens to simple values only (keywords/variables)
Complex conditions like `not 2 < 1` still require parentheses,
keeping alignment with CSS media query syntax. Only simple bare
values (keywords, variables, quoted strings) are allowed after
`not` without parens: `not false`, `not @var`.
Remove the `boolean(not 2 < 1)` test case that relied on the
broader atomicCondition fallback.
Co-authored-by: matthew-dean <[email protected]>
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: matthew-dean <[email protected]>
Co-authored-by: Matthew Dean <[email protected]>not keyword silently ignored when used without parentheses in conditions (#4421)1 parent 2958e9d commit d250d62
5 files changed
Lines changed: 38 additions & 1 deletion
File tree
- packages
- less/lib/less/parser
- test-data/tests-unit
- functions
- mixins-guards
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2438 | 2438 | | |
2439 | 2439 | | |
2440 | 2440 | | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2441 | 2452 | | |
2442 | | - | |
2443 | 2453 | | |
2444 | 2454 | | |
2445 | 2455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
| |||
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
| 241 | + | |
| 242 | + | |
239 | 243 | | |
240 | 244 | | |
241 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
259 | 262 | | |
260 | 263 | | |
261 | 264 | | |
| |||
271 | 274 | | |
272 | 275 | | |
273 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
274 | 280 | | |
275 | 281 | | |
276 | 282 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
0 commit comments