connorskees / grass

A Sass compiler written purely in Rust
https://docs.rs/grass/
MIT License
499 stars 38 forks source link

Using `auto` keyword with `min` function fails to compile #87

Open dxrcy opened 1 year ago

dxrcy commented 1 year ago

The below SCSS code should compile, verbatim, to CSS, but fails to compile with "auto is not a number".

div {
    width: min(200px, auto);
}

Expected: no change to file, because it is already valid and correct CSS.

Minimal example:

fn main() {
    let scss = r#" div { width: min(100px, auto); } "#;
    let css = grass::from_string(scss, &grass::Options::default());
    println!("{:#?}", css);
    assert!(css.is_ok(), "Failed to compile");
}

Same result is found using 100% or 100vw instead of 100px, or switching argument order.

I would assume that min is a SCSS function (as well as CSS), expecting literal or variable arguments, not auto keyword. The error can be bypassed by not including brackets in the function call, eg. width: min 100px, auto;.

I assume this is unintended behaviour, as I could not find an explaination online or in the documentation.

connorskees commented 1 year ago

This does look like a bug. Let me take a look at what's going on here and release a fix.