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
VOID pattern matching now covers type/declaration, constant/null, relational, logical, property, and recursive patterns, then carries the same semantics into switch cases, guarded cases, and expression-form switch.
Completed pattern-matching foundation
Patterns reuse normal type relationships, conversions, property access, definite assignment, short-circuiting, interface/value semantics, and GC-safe temporaries. Switch patterns and switch expressions build on the same matcher instead of introducing separate pattern rules.
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"
};