We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
odin report
this piece of code compiles
package test import "core:fmt" Foo :: struct($T: typeid) { val: T, a: Foo(T), b: Foo(T), } make_foo :: proc($T: typeid, v: T) -> Foo(T) { return new_clone(Foo{val = v}) } main :: proc() { f := make_foo(int, 1) }
compiler hangs indefinitely
The text was updated successfully, but these errors were encountered:
It is a bug, but the code as provided wasn't going to compile because Foo incorporating itself is a cycle. This does work:
Foo
package test import "core:fmt" Foo :: struct($T: typeid) { val: T, a: ^Foo(T), // Can't be `Foo(T)` because a struct can't contain itself. b: ^Foo(T), } make_foo :: proc($T: typeid, v: T) -> ^Foo(T) { // `new_clone` returns a pointer return new_clone(Foo(T){val = v}) // `Foo{val = v}` had to become `Foo(T){val = v}` } main :: proc() { f := make_foo(int, 1) fmt.println(f) // &Foo($T=int){val = 1, a = <nil>, b = <nil>} }
Sorry, something went wrong.
Having said that, it doesn't hang for me so much as fail with a stack overflow.
Odin: dev-2024-12:d3f072835 OS: Windows 10 Professional (version: 22H2), build 19045.4780 CPU: AMD Ryzen 9 5950X 16-Core Processor RAM: 65444 MiB Backend: LLVM 18.1.8
No branches or pull requests
Context
odin report
output:Odin: dev-2024-12
OS: Gentoo Linux, Linux 6.6.62-gentoo-dist
CPU: 13th Gen Intel(R) Core(TM) i5-13400F
RAM: 31927 MiB
Backend: LLVM 19.1.4+libcxx
Expected Behavior
this piece of code compiles
Current Behavior
compiler hangs indefinitely
Steps to Reproduce
The text was updated successfully, but these errors were encountered: