JSAbrahams / mamba

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

Type alias gives undefined error in type checker #264

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 2 years ago

Description of Bug

As a result of merging #263 , a different bug has been created. However, instead of fixing that in that PR, we should fix it separately since it would slightly change the structure of the checker.

When using an alias, the type checker trips up as it assumes that the alias should be in the environment. Instead, it should add these to the environment.

How to Reproduce

with my_resource as other do
    do_something(other)

Gives:

Error: [error | type] Undefined variable: other
 --> path/to/file:5:21
   5 | with my_resource as other do
                           ^^^^^
   6 |     do_something(other)

Expected behavior

When in type alias mode, the variables should be added to the environment instead of erroing if they are not there.