Skip to content

perry-codegen: String.slice() 0-arg form unsupported #316

Closed

Description

@proggeramlug

What happened

Perry's codegen rejects the standard String.prototype.slice() 0-arg form (a common idiom for "clone this string") with:

perry-codegen: String.slice expects 1 or 2 args, got 0

Surfaced compiling effect/src/internal/redBlackTree/iterator.ts::RedBlackTreeIterator::clone during the #309 compat sweep.

What you expected

MDN spec for String.prototype.slice: all of slice(), slice(start), and slice(start, end) are valid. The 0-arg form returns the whole string.

Minimal reproduction

const s = "hello";
const copy = s.slice();
console.log(copy);   // expected: "hello"
perry compile repro.ts -o /tmp/out
# fails with: perry-codegen: String.slice expects 1 or 2 args, got 0

Likely fix site

crates/perry-codegen/src/lower_string_method.rs — search for the slice arm. Treat 0 args as slice(0, length) (i.e. clone). Same fix shape that Array.prototype.slice() (without args) already supports.

Environment

  • Perry version: 0.5.405
  • Host OS: macOS 26.4 (arm64)
  • Target: native
  • Effect version: 3.21.2 (where this surfaced)

Discovered as part of the #309 long tail.

Activity

  1. proggeramlug commented on Apr 30, 2026

    @proggeramlug
    ContributorAuthor

    Tracked under umbrella #321 (Effect framework end-to-end compat).

  2. added 3 commits that reference this issue on Apr 30, 2026
    c4ea540
    e626a07
    7a69804
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