AnyDSL / impala

An imperative and functional programming language

Home Page:https://anydsl.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot return tuple type

madmann91 opened this issue · comments

The following code crashes :

type Blob = (i32, i32);
fn blobify(i: i32) -> Blob {
    (i, i)
}

fn main() -> () {
    let b = blobify(42);
}

Run with -emit-thorin.

Can you plz commit an appropriate test in impala/test/codegen?
Thx.

  • for codegen tests we either need to return true to pass them or we need to submit an appropriate output file the test suite can compare with
  • also, simply mention the issue number in the commit message; the commit will be automatically referenced in the issue

The bug hast to do with this weird thing that
fn(A) -> (B, C)
is
fn(A, fn(B, C))
and not
fn(A, fn((B, C)).
This is already dealt with in ther parser when parsing the -> (. So with the typedef above. The type would be:
fn(A, fn((B, C)).
But at some point, it gets mixed up. The correct fix would be to have in the type system that
T == (T)
but this is not going to happen any time soon. I'll try to find a workaround.

this one is really nasty. Would it be ok for you to postpone a fix for this bug?

Oh, forgot to mention that withouth the typedef the code works. As I mentioned: The reason is that fn() -> (...) is parsed in a special way.

Fixed in master.