Skip to content

Using currentcolor in color-mix() crashes (entered unreachable code) #522

@chris-morgan

Description

@chris-morgan

Using lightningcss@1.21.0 from npm.

$ node
Welcome to Node.js v20.2.0.
Type ".help" for more information.
> test=value=>(require("lightningcss")).transform({code:Buffer.from(`x{x:color-mix(in srgb,${value},blue)}`),minify:true}).code.toString()
[Function: test]

If you use two regular colours, it mixes them itself (✓):

> test`red`
'x{x:purple}'

If you use a variable, it skips it (✓):

> test`var(--x)`
'x{x:color-mix(in srgb,var(--x),blue)}'

But if you use currentcolor, it thinks it can do it because it’s a <color>, but it can’t actually since it’s resolved at runtime, and crashes (✘):

> test`currentcolor`
thread '<unnamed>' panicked at 'internal error: entered unreachable code', src/values/color.rs:2923:12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Wouldn’t surprise me if currentcolor could cause other crashes too. I haven’t gone looking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions