VOID Language patterns

Match structure.
Keep control flow readable.

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

Flow-sensitive matching built on the type system already underneath VOID.

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.

Declaration patterns

value is Type name narrows the matched value and introduces a pattern local only where the match establishes it as definitely assigned.

Constant & null patterns

Constants and null flow through the same pattern machinery, so they compose naturally with logical and switch patterns.

Relational patterns

<, <=, >, and >= patterns reuse VOID's existing numeric and comparison semantics.

Logical patterns

and, or, and not compose patterns with short-circuiting and flow-aware variable-binding rules.

Property patterns

Classes, structs, interfaces, inherited properties, and nullable/reference receivers can be matched through ordinary getter semantics.

Recursive patterns

Nested property patterns preserve single evaluation, GC-safe temporary receivers, pattern-local flow, and nullable/value behavior.

Pattern switch statements

Existing switch statements now accept typed and recursive case patterns while retaining normal switch ordering, grouping, break/continue, and legacy constant behavior.

Guards & ordering

when guards participate in deterministic first-match case ordering, with focused diagnostics for invalid or reliably unreachable combinations.

Switch expressions

Expression-form switch unifies result types across managed/value results, nullable values, conversions, and the same target-typing machinery used by conditional expressions.

Pattern locals across yield

Declaration, 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.

Declaration + logical pattern
object value = FindActor();

if (value is Player player)
{
    Console.WriteLine(player.Name);
}
Recursive property pattern
if (actor is Player
    {
        Health: > 0,
        Inventory: Inventory { Count: > 0 }
    } player)
{
    UseFirstItem(player);
}
Guarded switch + switch expression
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"
};