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

Nested SCSS function calls with leading dash are interpreted as unary minus #15369

Closed
threema-danilo opened this issue Sep 7, 2023 · 1 comment · Fixed by #15370
Closed
Labels
lang:css/scss/less Issues affecting CSS, Less or SCSS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@threema-danilo
Copy link

Prettier 3.0.3
Playground link

--parser scss

Input:

@function -double($value) {
  @return $value * 2;
}

.selector {
  font-size: -double(-double(1em));
}

Output:

@function -double($value) {
  @return $value * 2;
}

.selector {
  font-size: -double(- double(1em));
}

Expected behavior:

Dashes are valid parts of SCSS function names. You can test this by pasting the following snippet at https://www.sassmeister.com/:

@function -double($value) {
  @return $value * 2;
}

.selector {
  font-size: -double(-double(1em));
}

However, if a function call is nested, the inner leading dash is interpreted as unary minus, and a space is inserted. This breaks the SCSS function call.

@fisker fisker added type:bug Issues identifying ugly output, or a defect in the program lang:css/scss/less Issues affecting CSS, Less or SCSS labels Sep 7, 2023
@threema-danilo
Copy link
Author

The same thing happens within lists: Playground link (see width: -double(1em);).

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Dec 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:css/scss/less Issues affecting CSS, Less or SCSS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants