type.match_wildcard_required
A match on text or a number lists some values but has no _ arm for all the others.
Area 3, Logic; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
A match must cover every value it can be given. An enum's cases can all
be listed, but text and numbers have more values than any list of arms.
Arms for "" or 0 pick out a few of them, and _, as the last arm,
says what to do with the rest. Without it, the match has nothing to do
for most values.
What it looks like
The Label text type is declared in another file of the project,
shapes.jadpo.
main.jadpo:
function shout(label: Label) -> Label { return match label { "" -> "unnamed" }}
error This match needs a _ arm
--> main.jadpo:2:12
|2 | return match label { | ^^^^^^^^^^^ not every value is matched
- reason
Labelis built onText, so its values can't all be listed;_matches every value the arms above it don't.- next
- Add
_ -> ...as the last arm (agent) - rule
- type.
match_ wildcard_ required - help
- https://jadpo.
dev/docs/errors/type. match_ wildcard_ required
(agent) at the end of the next: line means your coding agent can make
the fix itself.
How to fix it
If the other values all get the same result, add _ as the last
arm, with what to do for them:
return match label { "" -> "unnamed" _ -> label }
An empty label becomes "unnamed", and any other label is kept as it is.
_ is only for values whose cases can't be listed: on an enum, a Bool
or a value that may be none, each case gets its own arm
(type.match_wildcard_closed).
Related
Markdown for agents: /docs/errors/type.match_wildcard_required.md.Built from Jadpo main at aee2e8f.