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

Circular scope compilation bug #1188

Open
TizzySaurus opened this issue Oct 30, 2024 · 2 comments
Open

Circular scope compilation bug #1188

TizzySaurus opened this issue Oct 30, 2024 · 2 comments
Assignees
Labels
bug Something isn't working confirmed The maintainers of the repo would like to address this

Comments

@TizzySaurus
Copy link
Contributor

Report a bug

🔎 Search Terms

circular scope, scope compilation bug, Apply is not a function.

🧩 Context

  • ArkType version: 2.0.0-rc.21
  • TypeScript version (5.1+): Version 5.7.0-dev.20241002
  • Other context you think may be relevant (JS flavor, OS, etc.): N/A

🧑‍💻 Repro

Minimum repro:

import { scope, type } from "arktype"

const $ = scope({
    Foo: {
        "oneOf?": "Bar[]" // NB: don't get the error if this is not an array
    },
    Bar: "Foo"
}).export()

const baz = $.Bar.pipe((_: object): type.Any | undefined => {
    console.log("this never gets logged since pipe isn't entered")
    return type("string")
})

const r = baz({ oneOf: [{}] }) // throws "TypeError: this.Foo1Apply is not a function"
console.log(r)
@TizzySaurus TizzySaurus added the bug Something isn't working label Oct 30, 2024
@github-project-automation github-project-automation bot moved this to To do in arktypeio Oct 30, 2024
@Kal-Aster
Copy link

I encountered this right now 💀

Meanwhile is there any workaround?

@ssalbdivad ssalbdivad added the confirmed The maintainers of the repo would like to address this label Jan 3, 2025
@ssalbdivad
Copy link
Member

ssalbdivad commented Jan 26, 2025

As a temporary workaround, you can try passing { jitless: true } to your scope since this issue seems specific to precompilation:

const types = scope(
	{
		Foo: {
			"oneOf?": "Bar[]"
		},
		Bar: "Foo"
	},
	{
		jitless: true
	}
).export()

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

3 participants