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

Enable recursion #3018

Open
mohammadfawaz opened this issue Oct 12, 2022 · 3 comments
Open

Enable recursion #3018

mohammadfawaz opened this issue Oct 12, 2022 · 3 comments
Assignees
Labels
compiler: codegen Everything to do with IR->ASM, register allocation, etc. compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen P: critical Should be looked at before anything else

Comments

@mohammadfawaz
Copy link
Contributor

Now that function calls have been (mostly) implemented, we can start looking into enabling recursion. There may be a few checks that we should remove and make sure that we're not recursively inlining function bodies in the AST.

@mohammadfawaz mohammadfawaz added compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen P: critical Should be looked at before anything else compiler: codegen Everything to do with IR->ASM, register allocation, etc. labels Oct 12, 2022
@otrho
Copy link
Contributor

otrho commented Oct 16, 2022

I think ideally we'd remove AST inlining altogether before enabling recursion. The issue is we still don't globally name everything in the AST, so it's possible for functions with the same local name to be confused.

But yeah, I'm sure we could add some hacks to keep inlined AST but ensure that recursion is still correct, maybe with some simple function tagging to distinguish same named functions.

@Voxelot
Copy link
Member

Voxelot commented Nov 28, 2023

@tritao what is the current state of this?

@tritao
Copy link
Contributor

tritao commented Nov 29, 2023

Recursion seems to work at a codegen-level, but we need to make some changes to the type checker and disable our recursion analysis checks to make this generally applicable.

esdrubal added a commit that referenced this issue Jan 24, 2024
ReplaceDecls, CollectTypesMetadata, HashWithEngines now have a mechanism that interrupts recursive visiting.

The mechanism works by adding TypeIds or DeclIds to a HashMap or HashSet and no longer visiting TypeIds or DeclIds on the passed collection.

This was necessary because in some cases while visiting a declaration we can go back to the beginning because of recursive DeclIds.

I suspect these changes will also be useful to #3018

This partially fixes #5504, which is still failing because we have yet to fix a recursion problem in the IR side of the compiler.
esdrubal added a commit that referenced this issue Jan 24, 2024
ReplaceDecls, CollectTypesMetadata, HashWithEngines now have a mechanism that interrupts recursive visiting.

The mechanism works by adding TypeIds or DeclIds to a HashMap or HashSet and no longer visiting TypeIds or DeclIds on the passed collection.

This was necessary because in some cases while visiting a declaration we can go back to the beginning because of recursive DeclIds.

I suspect these changes will also be useful to #3018

This partially fixes #5504, which is still failing because we have yet to fix a recursion problem in the IR side of the compiler.
esdrubal added a commit that referenced this issue Jan 25, 2024
ReplaceDecls, CollectTypesMetadata, HashWithEngines now have a mechanism that interrupts recursive visiting.

The mechanism works by adding TypeIds or DeclIds to a HashMap or HashSet and no longer visiting TypeIds or DeclIds on the passed collection.

This was necessary because in some cases while visiting a declaration we can go back to the beginning because of recursive DeclIds.

I suspect these changes will also be useful to #3018

This partially fixes #5504, which is still failing because we have yet to fix a recursion problem in the IR side of the compiler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: codegen Everything to do with IR->ASM, register allocation, etc. compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen P: critical Should be looked at before anything else
Projects
None yet
Development

No branches or pull requests

4 participants