Skip to content

Incorrect unnamed captures inference given alternationΒ #1530

Closed

Description

@codpro2005

Report a bug

πŸ”Ž Search Terms

ArkRegex,
regex,
captures,
alternation

🧩 Context

  • ArkRegex version: 0.0.2
  • TypeScript version (5.1+): 5.9.3

πŸ§‘β€πŸ’» Repro

Playground Link: https://www.typescriptlang.org/play/?target=99#code/JYWwDg9gTgLgBAbzlApgcxQDzgXzgMyghDgHIBDKAaxgE8wVSBuAKBYGMIA7AZ3mwC8ydFgAUpAHqiA-AC4ZAHnIA+AIwBKAD6KARsoBMWxe2UBmdeoAkpdQDpgXfCigBhcmBgBXVD1YB6PzgguAlpFgC4HgALCE8AGwATOB0UWThOXn40gG0AIlVcgBo4Ty4ElHwHFATi0vLKrmqAXThNOGy6iqqauFz9IpKyrsaElraOoYbq2snu4tzTXKagA

import { regex } from 'arktype';

const x = regex('^(?:(?<a>1)|(?<b>2)|(?<c>3))$').inferCaptures;
//    ^? const x: ["1"] | [undefined, "2"] | [undefined, "3"]
// should be: const x: ["1", undefined, undefined] | [undefined, "2", undefined] | [undefined, undefined, "3"]

Activity

  1. moved this from To do to Planned in arktypeioon Nov 18, 2025
  2. added a commit that references this issue on Oct 13, 2026
    196ced0
  3. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    Member

    Fixed in 3.0.0-beta.0 (#1728). Try it with npm i arktype@next.

  4. moved this from Planned to Done (merged or closed) in arktypeioon Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status
    Done (merged or closed)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions