Skip to main content

Module patterns

Module patterns 

Source
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 ... matches statement. The bindings’ Statement::expr has no PatternCase arm, 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. None when stmt is not a PatternCase or 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 by SymbolUid::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.