AnyDSL/impala

Incompatible named structs not rejected by sema

richardmembarth opened this issue · 1 comments

The following code types: impala test.impala

struct S1 {
    a : i32
}
struct S2 {
    a : i32
}

fn get2(a: i32) -> S2 { get1(a) }
fn get1(a: i32) -> S1 { S1 { a : a } }

fn main(i: i32) -> i32 {
    get2(i).a
}

But asserts when generating llvm impala -emit-llvm test.impala:

impala: thorin/src/thorin/util/cast.h:26: L* thorin::scast(R*) [with L = thorin::PrimType; R = thorin::Type]: Assertion `(!r || dynamic_cast<L*>(r)) && "cast not possible"' failed.
Aborted (core dumped)

get2() returns S2, but get1() gives S1. This should be detected by Sema.

Fixed by e4dfabb.