AnyDSL / thorin

The Higher-Order Intermediate Representation
https://anydsl.github.io
GNU Lesser General Public License v3.0
150 stars 15 forks source link

Array equality #13

Closed madmann91 closed 9 years ago

madmann91 commented 9 years ago

Array equality is authorized in Impala, but not supported by Thorin. The following code breaks :

extern "C" {
    fn puts(&[u8]) -> ();
}

fn main() -> () {
    let a = [1, 2];
    let b = [3, 4];
    if a == b {
        puts("arrays are equal");    
    }
}

It generates the following assertion :

impala: /space/perard/sources/thorin/src/thorin/util/cast.h:29: L* thorin::scast(R*) [with L = thorin::VectorTypeNode; R = thorin::MagicCast<thorin::TypeNode>]: Assertion `(!r || dynamic_cast<L*>(r)) && "cast not possible"' failed.

Should I implement it ? Or should it be forbidden in the front-end ?

leissa commented 9 years ago

Should be forbidden in the front-end. Can you have a look into the semantic analysis?

madmann91 commented 9 years ago

Ok. I'll do that then. But the possibility of comparing two definite size arrays was practical, I must say.

leissa commented 9 years ago

once we have operator overloading we can re-implement that feature in the library.