
Minus signs in SCSS are a little tricky. $a - $b is a subtraction, -$b is a negative value, and 1px 2px is a list. A formatter has to read every minus sign exactly the way Sass does, or it quietly changes your CSS.
That's what issue #12957 was about. The reporter had this:
$s: 8px;
.a {
margin: -#{$s} -#{$s} -#{$s} auto;
}
and Biome formatted the value as -#{$s} - #{$s} - #{$s} auto. Looks like a spacing tweak. It isn't. The reporter checked with Dart Sass: the original compiles to margin: -8px -8px -8px auto;, the formatted file to margin: -8px-8px-8px auto;. That's invalid CSS, so the browser drops the whole declaration.
I picked it up, and the fix was merged in biomejs/biome#12983.
Why it happened
The formatter wasn't really the problem. It prints the tree the parser gives it. The SCSS parser decides what counts as a binary operator in crates/biome_css_parser/src/syntax/scss/expression/precedence.rs, and its scss_binary_precedence function took every - after a value as subtraction. So -#{$s} -#{$s} became "negative #{$s}, minus #{$s}". Once the tree says subtraction, the formatter prints spaces around the operator.
Sass reads it differently. A - written directly against #{ starts an interpolated identifier. With a space before it, that's simply the next item in the list. Only $a - #{$s}, with a space on both sides, subtracts.
The fix
Both parse_scss_binary_tail and is_at_scss_binary_operator go through scss_binary_precedence, so one check there covers both. I added a small helper:
/// Returns whether the current `-` starts the next item of a space-separated
/// list instead of subtracting: it follows whitespace and is written directly
/// against an interpolation.
///
/// Sass reads a `-` followed by `#{` as the start of an interpolated
/// identifier, so `-#{$s} -#{$s}` is a two-item list (`-8px -8px`), while
/// `$a - #{$b}` subtracts.
///
/// Docs: https://sass-lang.com/documentation/operators/numeric/#unary-operators
#[inline]
fn is_at_scss_negated_interpolation_list_item(p: &mut CssParser) -> bool {
p.at(T![-])
&& (p.has_nth_preceding_whitespace(0) || p.has_nth_preceding_line_break(0))
&& is_nth_at_scss_interpolation(p, 1)
&& is_nth_source_tight(p, 1)
}
In words: a minus, with a space or a line break before it, followed by #{ with nothing in between. When that's true, it's not a binary operator:
if !p.at_ts(SCSS_BINARY_OPERATOR_TOKEN_SET) || is_at_scss_negated_interpolation_list_item(p) {
return None;
}
I kept it narrow on purpose. It only looks at #{, so height: 1 -$s; still parses as a subtraction, same as before.
Tests, and two snapshots that moved
I added the same input as a parser spec and a formatter spec:
$s: 8px;
.a {
margin: -#{$s} -#{$s} -#{$s} auto;
padding: 1px -#{$s};
width: $a - #{$s};
height: 1 -$s;
inset: -#{$s}
-#{$s};
}
The formatter now leaves margin and padding as written, keeps $a - #{$s} as a subtraction, prints height as 1 - $s like it always did, and joins the two line inset into -#{$s} -#{$s}. Both specs fail without the parser change.
Two existing snapshots changed too. In the Prettier compatibility snapshot parens.scss, the line prop25-4 used to come out as #{$width} - #{$width} where Prettier keeps #{$width} -#{$width}. Now Biome matches Prettier on that pair.
The bigger one showed up when I ran the whole parser suite. The ok/scss/value/minus-operator.scss snapshot, a matrix of subtraction cases, had 17 cases recorded as subtractions, all of the same shape: a space before, the minus tight against #{, like 10 -#{10} and #{10} -#{10}. I checked them against Sass's own conformance tests in sass/sass-spec, and Sass's expected output keeps every one of them as separate values. So I updated that snapshot as well.
ematipico merged it on 6 November 2026, the same day I opened it, with no changes asked. Thanks!
What I'm keeping from this one
When a formatter changes what your code means, look at the parser first. The formatter here did exactly what the tree told it to.
The reporter's compiled output was the best part of the issue. -8px-8px-8px next to -8px -8px -8px made the bug obvious in one line.
And run the whole suite, not only your new tests. Those 17 cases sat in an existing snapshot.
Do you write negative interpolations like this in your SCSS, or do you wrap them in parentheses to be safe? I'd like to hear what your team does.
About the author
- I contribute to open source developer tools: Tauri, Biome, oxc, Julia, Quarkus, Grafana, Burn and a few more. I start from an issue I can reproduce and a test that fails, then fix it. Here I write up the ones worth telling: what broke, why, and how the fix got through review.
Comments
Join the discussionNo comments yet. Be the first to comment.


