johnynek / bosatsu

A python-ish pure and total functional programming language
Apache License 2.0
224 stars 11 forks source link

Track Pattern Regions #132

Open johnynek opened 5 years ago

johnynek commented 5 years ago

Anything we parse should keep the region it came from, but in particular, without knowing the Pattern regions, we can't give very nice error messages.

The right way to do this is probably add a generic tag to Pattern, and that tag can carry a region.

johnynek commented 4 years ago

Here is a bad example:

in file: test_workspace/AvlTree.bosatsu, package AvlTree, type error: expected type Tree to be the same as type Bosatsu/Predef::Option
71|    recur tree:
72|        Empty: None
73|        Branch { key, left: None, ... }: Some(key)
                                            ^^^^^^^^^

we point to the expression, even though it is the Pattern that has the type error, it should be left: Empty not left: None but since we have no region for the Pattern we do the best we can, but it misleads.