feat(language): a cased expression writes its fallback as otherwise, outside the cases - #251
Merged
Merged
Conversation
Documentation build overview
16 files changed ·
|
…outside the cases The value wherever no `when` holds moves out of `cases:` and becomes the block's own `otherwise:`, so no name inside `cases:` is reserved and the cases carry no order. Five hand-written errors policing `default` are replaced by the closed schema's own: a required `otherwise:`, a required `when:` on every case, and `min_length=1` on `cases:`. The fallback's dims are checked where the cases' are, which the loop over `cases:` used to give it for free.
FabianHofmann
force-pushed
the
feat/cases-otherwise
branch
from
August 30, 2026 11:10
7bc20f0 to
b2cd7aa
Compare
Contributor
|
Good reasons! |
Contributor
Author
|
math calls it otherwise ( |
FBumann
approved these changes
Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the change I asked for on #168. Stacked on
feat/cases-proved-apart.Note
The following content was generated by AI.
The value wherever no
whenholds moves out ofcases:and becomes the block's ownotherwise:. No name insidecases:is reserved, and the cases carry no order — so a file a key-sorting formatter produced says what it said before._default_is_the_last_caseis deleted, and with it the five hand-written errors that policed a reserved name inside a map of user-chosen ones:default"a `cases:` block needs an `otherwise:`defaultis written last"default"min_length=1oncases:, published in the schemadefaultcarries awhen:"openingcarry nowhen:"when:One message the table did not have:
otherwise:written withoutcases:, the mirror of the missing one, which no schema constraint catches.The three golden
.outfiles do not change. The rendered maths is identical, which is the check that this is input-only.What was not just a spelling change
dimensions.pynever checked the fallback's dims. Withdefaultinsidecases:it came along in the loop for free; outside, it would have escaped, and a value carrying a dim the frame lacks would have reached lowering. The frame check now runs over the cases' values andotherwise, sootherwise: loadunderforeach: [generator]is still aDimensionError.test_a_case_may_not_widen_the_framemoved onto the new spelling and fails without the fix.validation.pylikewise now checks theotherwisebody for unknown names, comparisons and the ceiling.Everything downstream of the parse is untouched.
expansion._parse_casedappends the fallback as the lastCaseArmwithwhen=None, soCasesNode, resolution, lowering,walk.py— which already found the fallback byarm.when is Nonerather than by name or position — the dim algebra and boundedness see exactly what they saw before.Checks
pixi run ciclean:lint, 877 passed,mkdocs build --strict, 27 TeX documents compiled.877 against the base branch's 880: the five
default-shape parametrized cases are replaced by two form cases (no-otherwise,otherwise-alone) and two shape tests (..._says_where_it_applies,..._carries_at_least_one_case).Not done here: the base PR's body still describes the
defaultdesign. It wants rewriting rather than appending to, and that belongs on #168 once this lands.