Skip to content

Parser should catch error on duplicate keys in maps #628

@lunelson

Description

@lunelson

So, ruby-sass throws an error when a map is declared that has any duplicate keys, including any at nested levels. i.e. maps that are values or keys within other maps:

$map: (
  alpha: 1,
  beta: 2,
  gamma: 3,
  delta: (
    eta: 5,
    eta: 6,
  ),
);
Duplicate key "eta" in map (eta: 5, eta: 6).

Libsass currently does not run this check, and should; however, libsass can also do better than ruby-sass here. Note that ruby-sass fails to pick up duplicate-key maps that result from other operations. Example:

$map1: (
  alpha: 1,
  beta: 2,
  gamma: 3,
);

$map2: (
  alpha: 2
);

$map3: join($map1, $map2);

.test {
  out: inspect($map3);
}
.test {
  out: alpha 1, beta 2, gamma 3, alpha 2;
}

So imo libsass should have a map-validity check routine that runs on anything that involves SassScript maps or lists (as the latter may contain a map) as outputs or assignments.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions