eeue56 / derw

An Elm-inspired language that transpiles to TypeScript
BSD 3-Clause "New" or "Revised" License
378 stars 9 forks source link

Type check and code generation for let expression is broken #10

Closed phenax closed 1 year ago

phenax commented 2 years ago

I was experimenting with the language on the playground and tested out the following code

fn: number -> string
fn =
    let y = 0
    in y

Expected

Observed

Results in the following code which is invalid.

function fn(_0: number): string {
    return y;
}

The value given to y doesn't matter since it seems to be completely ignored.

eeue56 commented 2 years ago

Nice! Thanks for the report. The type inference is a work in progress at the moment - but this one should be an easy fix.

janwirth commented 2 years ago

I also think the examples should not compile due to mismatch number of arguments in signature and definition.

eeue56 commented 1 year ago

This is an error now:

Expected `string` but got `number` in the body of the function:

fn: number -> string 
fn x = 
    let 
        y: number 
        y = 0
    in 
        y

Mismatching number of arguments in signature vs definition is kinda intended currently