Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some cyclic unions incorrectly reduced #1209

Open
ssalbdivad opened this issue Nov 22, 2024 Discussed in #1197 · 1 comment
Open

Some cyclic unions incorrectly reduced #1209

ssalbdivad opened this issue Nov 22, 2024 Discussed in #1197 · 1 comment
Labels
bug Something isn't working confirmed The maintainers of the repo would like to address this

Comments

@ssalbdivad
Copy link
Member

ssalbdivad commented Nov 22, 2024

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?

@github-project-automation github-project-automation bot moved this to To do in arktypeio Nov 22, 2024
@ssalbdivad ssalbdivad changed the title Arrays of literals and recursive objects don't seem to mix well Some cyclic unions incorrectly reduced Nov 22, 2024
@ssalbdivad
Copy link
Member Author

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

@ssalbdivad ssalbdivad added bug Something isn't working confirmed The maintainers of the repo would like to address this labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed The maintainers of the repo would like to address this
Projects
Status: Backlog
Development

No branches or pull requests

1 participant