[csswg-drafts] [css-values-4] "Simplify a calculation tree" doesn't return in all paths (#11572)

AtkinsSJ has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values-4] "Simplify a calculation tree" doesn't return in all paths ==
Based on the current css-values-4 [simplify a calculation tree](https://drafts.csswg.org/css-values-4/#calc-simplification) algorithm.

Specifically, if `root` is an operator node that is not a calc-operator node, and there is not enough information to compute its operation, then we end up reaching the end of the algorithm.

For example, if we enter the algorithm with `root` being `min(1em + 2em, 10px)`, and not enough information to convert an em to px:

- Steps 1 and 2 are skipped.
- Step 3, "At this point, root is an operator node. Simplify all the calculation children of root." will simplify the sum node. So we get `min(3em, 10px)`.
- Step 4 does not have enough information to compute the `min()` operation, so it's skipped.
- No subsequent step handles a `min()` operation, so we go off the end of the algorithm.

I think the solution is just to add a catch-all final step of "Return _root_." I'll submit a PR momentarily.

Alternatively, step 4 could gain an "Otherwise, return _root_" substep. But this is complicated by the requirement to fall through to step 5 for Min and Max nodes. Personally I prefer the simpler solution.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11572 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 27 January 2025 09:56:01 UTC