Declaration patterns
value is Type name narrows the matched value and introduces a pattern local only where the match establishes it as definitely assigned.
VOID Language patterns
Pattern matching extends ordinary type and property semantics into readable control flow. The same matcher powers is, switch cases, guards, and switch expressions so the rules do not change with the syntax.
Completed pattern-matching foundation
Patterns are flow-sensitive, but they do not get a separate type system. They reuse ordinary type relationships, property access, definite assignment, and short-circuiting, while switch forms build on the same matcher.
value is Type name narrows the matched value and introduces a pattern local only where the match establishes it as definitely assigned.
Constants and null flow through the same pattern machinery, so they compose naturally with logical and switch patterns.
<, <=, >, and >= patterns reuse VOID's existing numeric and comparison semantics.
and, or, and not compose patterns with short-circuiting and flow-aware variable-binding rules.
Classes, structs, interfaces, inherited properties, and nullable/reference receivers can be matched through ordinary getter semantics.
Nested property patterns preserve single evaluation, GC-safe temporary receivers, pattern-local flow, and nullable/value behavior.
Existing switch statements now accept typed and recursive case patterns while retaining normal switch ordering, grouping, break/continue, and legacy constant behavior.
when guards participate in deterministic first-match case ordering, with focused diagnostics for invalid or reliably unreachable combinations.
Expression-form switch unifies result types across managed/value results, nullable values, conversions, and the same target-typing machinery used by conditional expressions.
yieldDeclaration, switch-case, switch-expression-arm, recursive-pattern, and guarded pattern locals are promoted through the existing iterator capture model when they must survive suspension, with their scope and GC lifetime preserved.
One pattern engine
is, switch, and switch expressions share the same semantics.VOID does not maintain separate implementations for each syntax form. Type tests, property access, recursive matching, pattern-local flow, ordering, and result typing build on compiler mechanisms that already power ordinary expressions and control flow.
object value = FindActor();
if (value is Player player)
{
Console.WriteLine(player.Name);
}if (actor is Player
{
Health: > 0,
Inventory: Inventory { Count: > 0 }
} player)
{
UseFirstItem(player);
}switch (actor)
{
case Player player when player.Health <= 0:
Respawn(player);
break;
case Player player:
Update(player);
break;
}
string state = actor switch
{
Player { Health: <= 0 } => "down",
Player { Health: > 0 } => "active",
null => "missing",
_ => "other"
};