c3lang / c3c

Compiler for the C3 language
GNU Lesser General Public License v3.0
1.34k stars 80 forks source link

Failing to compile List with pointer to interface #1203

Closed pherrymason closed 1 week ago

pherrymason commented 3 weeks ago

In version 0.5.5 this code is failing to compile:

module core::actions;
import std::collections::list;

interface Action {
    fn bool enter();
    fn bool update(float dt);
}

struct ActionList {
    char* name;
    List(<Action*>) actions;
}

With the error: FATAL ERROR Should be unreachable -> in sema_expr_analyse_type_access @ in /xxxxx/src/compiler/sema_expr.c:3116

Looks like the culprit is the List(<Action*>), as soon as I replace it with List(<int>) it compiles properly.

I'm on Mac aarch64. Built c3c with llvm: stable 18.1.6

lerno commented 3 weeks ago

I have fixed this in the dev branch.

pherrymason commented 3 weeks ago

Tested and working! Thanks!