asoffer / Icarus

An experimental general-purpose programming language
Apache License 2.0
9 stars 2 forks source link

Recursive overloads break when using short function syntax #99

Open perimosocordiae opened 2 years ago

perimosocordiae commented 2 years ago

This looks to be related to the way type verification is performed for short function definitions (where the return type is inferred).

Foo ::= (x: i64) => x
// Foo ::= (x: i64, y: i64) -> i64 { return Foo(x) }
Foo ::= (x: i64, y: i64) => Foo(x)

Error:

[140421545211720 compiler/context.cc:179] Assertion failed
    Expected: inserted == true
         LHS: false
         RHS: true
*** SIGABRT received at time=1639546172 on cpu 2 ***
PC: @     0x7fb6705c2808  (unknown)  pthread_kill
    @          0x1923ef0         64  absl::WriteFailureInfo()
    @          0x1923bd4        224  absl::AbslFailureSignalHandler()
    @     0x7fb67056e520  (unknown)  (unknown)
Aborted (core dumped)

If you uncomment the middle line and comment out the last line, then the overloads resolve as expected and everything works.

asoffer commented 2 years ago

That's right. Currently we break the verification step into two parts (signature then body) but keep them combined for short functions. We actually need three steps (parameters then return then body, combining the last two for short functions).