Skip to content

Some cyclic unions incorrectly reduced #1209

Closed

Description

@ssalbdivad

Discussed in #1197

Originally posted by agladysh November 12, 2024
A somewhat silly reduced example:

import { ArkErrors, scope } from 'arktype';

const $ = scope({
  literal: '"foo"',
  record: {
    '[string]': 'value'
  },
  value: 'literal|literal[]|record',
}).export();

const result = $.value({ });

if (result instanceof ArkErrors) {
  // Error: must be an array (was object)
  throw new Error(result.summary);
}

console.log('passed');

All three types in value seem to be necessary to reproduce the issue.

What am I doing wrong?

Activity

  1. changed the title [-]Arrays of literals and recursive objects don't seem to mix well[/-] [+]Some cyclic unions incorrectly reduced[/+] on Nov 22, 2024
  2. ssalbdivad commented on Nov 22, 2024

    @ssalbdivad
    MemberAuthor

    This is definitely a bug, likely to do with the way the recursive references and reduced in the union.

  3. added
    bug
    confirmed
    on Nov 22, 2024
  4. moved this from Backlog to Implemented in arktypeioon Apr 16, 2025
  5. moved this from Implemented to Done (merged or closed) in arktypeioon Apr 16, 2025
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

    Type

    No type

    Projects

    • Status
      Done (merged or closed)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions