lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Regression: color-mix()-ing with <system-color>s panics

Open toastal opened this issue 4 months ago • 0 comments

Browsers seem to handle types for color-mix() just fine. The latest version (1.24) of Lightning CSS however now fails parse this situation--previous versions were all fine. I happen to have a some older browsers set to be supported by my output too. I think it’s trying to interpolate & produce the output color as a fallback which it can never do for system colors. I would prefer it be left alone as a progressive enhancement in my case.

.foo {
	background: color-mix(in lab, Canvas 75%, CanvasText 25%);
}

With RUST_BACKTRACE=full

thread 'main' panicked at src/values/color.rs:3237:12:
internal error: entered unreachable code
stack backtrace:
   0:     0x555555ae94ec - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85e32f8f7b08f729
   1:     0x55555579ce90 - core::fmt::write::hae1cf5cde4ee2188
   2:     0x555555adea1d - std::io::Write::write_fmt::h4ae54bff47727b29
   3:     0x555555af65ce - std::sys_common::backtrace::print::hea248a594c5888cf
   4:     0x555555af61a0 - std::panicking::default_hook::{{closure}}::h545cae1ad29f25d2
   5:     0x555555af6dbf - std::panicking::rust_panic_with_hook::h0e7975574d129b7c
   6:     0x555555af67a8 - std::panicking::begin_panic_handler::{{closure}}::h420dcc10a77211ab
   7:     0x555555af6736 - std::sys_common::backtrace::__rust_end_short_backtrace::he6597460302ecd4a
   8:     0x555555af6721 - rust_begin_unwind
   9:     0x555555585a64 - core::panicking::panic_fmt::h3cf3338e18ada46e
  10:     0x555555585ab2 - core::panicking::panic::h751818a9309dd3b6
  11:     0x5555559979f2 - lightningcss::values::color::CssColor::interpolate::hff37059daed6912f
  12:     0x555555995f0e - cssparser::parser::parse_nested_block::h3671bd0307999e16
  13:     0x5555557d819e - <lightningcss::values::color::CssColor as lightningcss::traits::Parse>::parse::h3d41d3ca12454c29
  14:     0x5555557dbe6f - lightningcss::properties::<impl lightningcss::traits::Parse for smallvec::SmallVec<T>>::parse::hc80e560653a12c6e
  15:     0x5555557c8fb2 - lightningcss::properties::Property::parse::h88f3b7e905e13d6f
  16:     0x5555557c6295 - lightningcss::declaration::parse_declaration::h6bd88964a31416c6
  17:     0x555555a9f32b - lightningcss::parser::NestedRuleParser<T>::parse_nested::h1dacc037658b3db2
  18:     0x55555564c0be - lightningcss::main::hd5149adb94fe3fc7
  19:     0x5555555d3c33 - std::sys_common::backtrace::__rust_begin_short_backtrace::h3c54c18a4b1fd668

It can also be seen failing on the Playground: https://lightningcss.dev/playground/index.html#{"minify"%3Atrue%2C"customMedia"%3Atrue%2C"cssModules"%3Afalse%2C"analyzeDependencies"%3Afalse%2C"targets"%3A{"chrome"%3A6225920}%2C"include"%3A0%2C"exclude"%3A0%2C"source"%3A".foo {\n\tbackground%3A color-mix(in lab%2C Canvas 75%25%2C CanvasText 25%25)%3B\n}"%2C"visitorEnabled"%3Afalse%2C"visitor"%3A"{\n%20 Color(color) {\n%20%20%20 if (color.type %3D%3D%3D 'rgb') {\n%20%20%20%20%20 color.g %3D 0%3B\n%20%20%20%20%20 return color%3B\n%20%20%20 }\n%20 }\n}"%2C"unusedSymbols"%3A[]%2C"version"%3A"local"}


Also, is there a mirror/outlet outside of proprietary Microsoft GitHub to discuss the project?

toastal avatar Feb 29 '24 09:02 toastal