kitlang / kit

Kit: a magical, high performance programming language, designed for game development.
https://www.kitlang.org
Other
1.02k stars 29 forks source link

Type inference is not working correctly #152

Open PtrMan opened 3 years ago

PtrMan commented 3 years ago

The compiler should infer types correctly and not push type-inference to the backend (C).

If this is a code issue, provide a minimal code example:

include "math.h";
function exp(v:(Float64,Float64)):(Float64,Float64) {
    var r = expf(v[0]);
    var d = 0.0;
    return (r,d);
}

gives a compile error from the gcc:

Error: build/lib/kit_test0.c: In Funktion »test0__exp«:
build/lib/kit_test0.c:19:12: Fehler: unverträgliche Typen bei Rückgabe von Typ »struct tuple2bf0b99cc56f6aa69d896315«, aber »struct tuplee7731a893109b41a186a62ef« wurde erwartet
   19 |     return (struct tuple2bf0b99cc56f6aa69d896315) {.__slot0 = r, .__slot1 = d};
      |            ^