JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
85 stars 3 forks source link

Nested ifs trip up type system #367

Closed JSAbrahams closed 1 year ago

JSAbrahams commented 1 year ago

Description of Bug

If we assign to a variable using an if expression, and use this in another if expression (condition), the type system fails to check. Same holds for if expression used as a for loop collection.

How to Reproduce

When running the following

def d := if a then b else c
def e := if d then b else c

Gives the following

Error: Cannot infer type. Expected a Bool, was `if`.__bool__(`if`)
 --> ...
   1 | def d := if a then b else c
   2 | def e := if d then b else c
                   ^

Expected behavior

It should pass since this is well typed.