Skip to content

Conditional rest parameter type cause args to be undefined #484

Closed

Description

@codehz

What happened

See min repro

What you expected

it should work like normal rest parameter

Minimal reproduction

// Minimal reproduction for Perry compiler bug:
// Conditional rest parameter type `T extends void ? [] | [void] : [T]`
// causes runtime TypeError: Cannot read properties of undefined (reading 'length')

class Builder {
  with<T>(id: number, ...args: T extends void ? [] | [void] : [T]): this {
    console.log("args.length:", args.length);
    return this;
  }
}

const b = new Builder();
b.with(1);
console.log("Done");

Command you ran:

perry test.ts && ./test

Environment

  • Perry version: 0.5.581
  • Host OS: ArchLinux
  • Target: native
  • Rust toolchain (if building from source): rustc 1.95.0 (59807616e 2026-04-14)
  • Installed via: from source

Diagnostic output

Perry Doctor

Environment Checks
──────────────────
  ✓ perry version: 0.5.581
  ✓ update status: up to date
  ✓ clang (LLVM codegen): clang version 22.1.3
  ✓ system linker (cc): cc (GCC) 16.1.1 20260430
  ✓ runtime library: /home/codehz/Projects/perry/target/release/libperry_runtime.a
  ⚠ project config (perry.toml): not found - run: perry init

All critical checks passed with some warnings.

Anything else

If change the rest parameter to any[] it will works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regression

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions