Expand description
Pattern matching (IEEE 1800-2023 12.6): what the analysis side needs.
A pattern variable (.n in tagged Valid .n) is bound when its pattern
matches and read by the later conditions and the matched branch. slang
gives it no declaration statement and, for a ?: pattern, no scope
either, so the declared-locals scans (process::liveness, a subroutine’s
locals) cannot find it as a block member: pattern_vars finds them in
the patterns themselves.
Functions§
- pattern_
case_ expr - The case expression of a
case ... matchesstatement. The bindings’Statement::exprhas noPatternCasearm, so it is the first expression among the statement’s semantic children (slang visits the case expression before the items); the other expression children are exactly the items’&&&filters, which is checked.Nonewhenstmtis not aPatternCaseor the children do not have that shape. - pattern_
vars - Every pattern variable bound anywhere in the subtree of
root(if (e matches p),case (e) matches,e matches p ? a : b), once each, in source order. Variables are told apart bySymbolUid::uid; a?:pattern’s variable lives in no scope, so two of them with the same name share a key (and a slot) – codegen refuses the pair when their types differ in width.