c3lang / c3c

Compiler for the C3 language
https://c3-lang.org
GNU Lesser General Public License v3.0
3.02k stars 183 forks source link

errors when using `@tag` to give a type definition a tag value of its own type #1583

Closed Book-reader closed 1 month ago

Book-reader commented 1 month ago

in the following example the compiler gives the error Recursive definition of 'Test'

struct Test @tag("test", Test{})
{
  int x;
}

the same happens with enum Test @tag("test", Test.FOO) {FOO} but with another message saying 'Test' has no enumeration 'FOO'

in the below example the compiler crashes with the message FATAL ERROR Should be unreachable -> in sema_identifier_find_possible_inferred @ in /home/runner/work/c3c/c3c/src/compiler/sema_expr.c:946

def @Test(Foo val) = {};

enum Foo @tag("test", Foo.BAR)
{
  BAR,
  BAZ
}

fn void main() @Test(BAR)
{
}

this only happens when:

lerno commented 1 month ago

This should work correctly now.

Book-reader commented 1 month ago

It no longer crashes, thanks!