JSAbrahams / mamba

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

Integrate tuples into type checker #201

Closed JSAbrahams closed 3 years ago

JSAbrahams commented 4 years ago

Relevant Issues

Implements #205

Summary

Keep track of tuple sizes, which can be statically determined, and give error if tuple sizes don't match during assignment.

Added Tests

JSAbrahams commented 3 years ago

Perhaps we should differentiate between tuples and list/sets/dictionaries (once we have dictionaries)

JSAbrahams commented 3 years ago

Turning out to be a bit more difficult than anticipated, but the trace messages are proving very helpful. This is however definitely something we want, tuples are sized at compile time, and collections at runtime, so we want to verify the size of tuples.

It seems that the union stage is struggling with tuples, the constraints that are generated initially (and not during the unification stage) seem to be correct, but I have to double check this. But I believe the error is in the unification stage (probably during substitution) currently, or there is some conceptual error in the generation stage.