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

Cyclic Type Checking #1

Closed
gingerBill opened this issue Dec 4, 2016 · 2 comments
Closed

Cyclic Type Checking #1

gingerBill opened this issue Dec 4, 2016 · 2 comments

Comments

@gingerBill
Copy link
Member

At the moment, there is no cyclic type checking and if a type has a cyclical definition, it will cause the compiler to go into an infinite loop.

Examples:

A :: type A

B :: type struct {
	c: C;
};

C :: type struct {
	b: B;
};
@ratchetfreak
Copy link

use a stack when you start into creating a type that not concrete yet, then each time you find a type used by value that's also not concrete (size unknown) walk up the stack and check if it is recursing and if not then push the new typ on the stack and finalize it once you are done finalizing pop it off the stack.

That or a loop counter that when it reaches some high enough value (like the total number of struct types visible in that scope) creates an error.

@gingerBill
Copy link
Member Author

I've just implement a (crude) cyclic type checking system by calculating the alignment or size of the type and keeping a path of the types. If that type is already in that path, an error will be printed of the illegal declaration cycle.

The cyclic checking should be done in the entity declaration stage but this works for now and is simpler to implement.

gingerBill pushed a commit that referenced this issue Oct 17, 2018
Fix syntax error in core/os/os_linux.odin
ThisDevDane pushed a commit that referenced this issue Aug 29, 2020
Merge pull request #724 from Skytrias/master
gingerBill pushed a commit that referenced this issue Jan 21, 2021
gingerBill pushed a commit that referenced this issue Mar 19, 2021
return by pointer on linux
Lperlind added a commit to Lperlind/Odin that referenced this issue Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants