pschachte / wybe

A programming language supporting most of both declarative and imperative programming
MIT License
47 stars 6 forks source link

Poor error message when ! on call is omitted #462

Open pschachte opened 6 months ago

pschachte commented 6 months ago

This code

resource to_parse:string

def {partial} digit(?d:int) use !to_parse {
    to_parse = [?ch | ?to_parse]
    ch >= '0' & ch <= '9'
    ?d = ord(ch) - ord('0')
}

def {partial} integer(?i:int) use !to_parse {
    digit(?i)
    do {
        while (!digit(?d))
        ?i = i * 10 + d
    }
}

Gives this misleading error message:

examples.wybe:97:5: Type error in partial application of proc digit, argument 1
examples.wybe:97:5: Type error in call to proc digit, argument 1

The actual problem is that the ! is omitted at the front of the first call to digit.