Zag-Research / Zag-Smalltalk

Smalltalk VM Written in Zig with methods stored as type-annotated ASTs
MIT License
133 stars 6 forks source link

weird compilation issue #3

Closed matu3ba closed 1 month ago

matu3ba commented 1 year ago
cd zig/zag
zig test -freference-trace --test-filter fubar arenas.zig

output

arenas.zig:69:26: error: struct 'arenas.Arena' depends on itself
pub const Arena = extern struct {
                  ~~~~~~~^~~~~~
referenced by:
    NurseryArena(509): arenas.zig:121:33
    NurseryArena: arenas.zig:116:19
    nurseryType: thread.zig:22:31
    Thread: thread.zig:18:15
    Self: thread.zig:21:18
    thread_size: thread.zig:23:48
    threadAvail: thread.zig:24:43
    nursery_size: thread.zig:25:31

fails repeatedly for me on linux-x86_64-gnu. Not only spuriously.

Related: #14353 https://github.com/ziglang/zig/issues/14147 https://github.com/ziglang/zig/issues/12325 https://github.com/ziglang/zig/issues/8050

matu3ba commented 1 year ago

At least from my point of view Sema log is very incomplete and gives no further hint, so it looks like debugging would be needed: https://gist.github.com/matu3ba/e0e4817c494dfff1b7dd3ef9a1f241e4

dvmason commented 1 year ago

I realized something today: it works if you zig test thread.zig but gives the recursive type error if you try anything else that loads arena.zig, so I think it's the loading of thread.zig that creates the problem, so if it's the first thing loaded, everything is cool, but if it's indirectly loaded, you get the "depends on itself" loop bug. You can see this by testing almost anything else (because almost everything eventually @imports thread and arena