swc-project/swc · error

Expected valid length (minimum 1 or maximum 6 hex digits) in

Error message

Expected valid length (minimum 1 or maximum 6 hex digits) in the end of unicode range

What it means

Fired during <urange> end-value validation: after the '-' separator, the end part must consist of 1 to 6 hex digits, but zero or more than six were found, making the range end invalid per the spec algorithm.

Source

Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:3031

            match next {
                Some(c) if c.is_ascii_digit() => {
                    end.push(c);
                    next = chars.next();
                }
                Some(c @ 'A'..='F') | Some(c @ 'a'..='f') => {
                    end.push(c);
                    next = chars.next();
                }
                _ => {
                    break;
                }
            }
        }

        let len = end.len();

        if len == 0 || len > 6 {
            return Err(Error::new(
                span,
                ErrorKind::Expected(
                    "valid length (minimum 1 or maximum 6 hex digits) in the end of unicode range",
                ),
            ));
        }

        if chars.next().is_some() {
            return Err(Error::new(
                span,
                ErrorKind::Expected("no characters after end in unicode range"),
            ));
        }

        return Ok(UnicodeRange {
            span: span!(self, span.lo),
            start: self.input.atom(start),
            end: Some(self.input.atom(end)),

View on GitHub (pinned to 5176682b65)

Solutions

  1. Use 1 to 6 hex digits for the range end, e.g. 'U+0-10FFFF'
  2. Ensure the end value is not empty after the '-'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:3031 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/14eb318c18dbb2d7. Report an issue: GitHub.