JSAbrahams / mamba

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

Accesses to collections' type cannot be identified #383

Closed JSAbrahams closed 1 year ago

JSAbrahams commented 1 year ago

Description of Bug

Introduced in #382 Mainly because we don't have an elegant system yet to resolve these constraints. The idea was that we resolve these at a later time in the process, but the unification stage does not yet do this. For some reason this was never identified due to the weird Raise logic we had there which is now removed.

How to Reproduce

def x := "my_string"

print(x[2])

Gives error

Error: Type '@0' is undefined.
 --> access_string.mamba:3:7
   3 | print(x[2])
             ^^^^

Which is the result of the the generate stage creating a temporary Name for the access (temporary as identified by the @). Perhaps this can be resolved another way, but for now the generate stage creates a constraint which cannot be solved by the unification stage.

JSAbrahams commented 1 year ago

Appears resolved, was false alarm. Though the reason for this working is a bit finicky so I want to do more elaborate tests with collection accesses. Leaving open for now.