Skip to content

Resolver crasher on recursive types #2633

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

Closed
N1ark opened this issue Jan 23, 2023 · 0 comments · Fixed by #2634
Closed

Resolver crasher on recursive types #2633

N1ark opened this issue Jan 23, 2023 · 0 comments · Fixed by #2634
Labels

Comments

@N1ark
Copy link

N1ark commented Jan 23, 2023

The type resolver crasher when parsing recursive types that reference each other (note no error is thrown if the recursive types are merged into one).

Stack trace:

RangeError: Maximum call stack size exceeded
    at Map.has (<anonymous>)
    at Qn.getMember (node_modules/assemblyscript/src/program.ts:2993:28)
    at Qn.getMember (node_modules/assemblyscript/src/program.ts:3252:25)
    at Qn.lookup (node_modules/assemblyscript/src/program.ts:3265:24)
    at mt.lookup (node_modules/assemblyscript/src/program.ts:2999:24)
    at qn.resolveTypeName (node_modules/assemblyscript/src/resolver.ts:589:30)
    at qn.resolveNamedType (node_modules/assemblyscript/src/resolver.ts:216:24)
    at qn.resolveType (node_modules/assemblyscript/src/resolver.ts:154:21)
    at qn.resolveNamedType (node_modules/assemblyscript/src/resolver.ts:321:23)
    at qn.resolveType (node_modules/assemblyscript/src/resolver.ts:154:21)

Code that crashes the resolver:

type RecMethod = () => RecReturn;
type RecReturn = RecMethod | null;

const test: RecMethod = () => null;

Equivalent code that doesn't crash the resolver (throws a AS100: Not implemented: Recursion in type aliases):

type RecMethod = () => RecMethod | null;
type RecReturn = returnof<RecMethod>;

const test: RecMethod = () => null;

Expected result: the resolver doesn't crash in both cases, and instead outputs the same (?) error (or at least handles the error in some way).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants