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

Correct hanlding of recursive type parameters #63

Open
kdy1 opened this issue Jul 2, 2021 · 0 comments
Open

Correct hanlding of recursive type parameters #63

kdy1 opened this issue Jul 2, 2021 · 0 comments

Comments

@kdy1
Copy link
Member

kdy1 commented Jul 2, 2021

Currently, type parameters are incorrectly stored, but when I tried storing them recursively, it resulted in a stack overflow.

https://github.com/swc-project/stc/blob/76e1a7d0c48ea2c9e78e97fba4f32187d31cd625/typescript/file_analyzer/src/analyzer/convert/mod.rs#L120-L131

I tried preventing stack overflow, but the 'validity' of type can't be ignored. Especially, Fixer cannot give up fixing types, because it makes validity assertion of a type fail.

Solutions

Solution 1: Allow invalid state

Allowing the constraints of type parameters to be invalid and fixing them each time contraint is used can be a solution, but it does not seem like a good solution.

Solution 2: Use Type::Ref for constraints.

This would make code dirty, but it would be easy to handle infinite recursion because many methods have their own logic to prevent infinite recursions. (fix() does not have way to prevent recursion, and it's the problem)

@kdy1 kdy1 added this to the 1. No false positive milestone Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant