unison/unison-src/transcripts/resolution-failures.md

55 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2021-10-07 01:56:56 +03:00
# Resolution Errors
This transcript tests the errors printed to the user when a name cannot be resolved.
## Codebase Setup
2024-07-02 19:46:40 +03:00
```ucm
scratch/main> builtins.merge lib.builtins
```
2021-10-07 01:56:56 +03:00
First we define differing types with the same name in different namespaces:
```unison
unique type one.AmbiguousType = one.AmbiguousType
unique type two.AmbiguousType = two.AmbiguousType
2021-10-07 23:43:08 +03:00
one.ambiguousTerm = "term one"
two.ambiguousTerm = "term two"
2021-10-07 01:56:56 +03:00
```
```ucm
2024-07-01 20:28:52 +03:00
scratch/main> add
2021-10-07 01:56:56 +03:00
```
## Tests
Now we introduce code which isn't sufficiently qualified.
2021-10-07 01:56:56 +03:00
It is ambiguous which type from which namespace we mean.
2021-10-07 23:43:08 +03:00
We expect the output to:
1. Print all ambiguous usage sites separately
2. Print possible disambiguation suggestions for each unique ambiguity
```unison:error
2021-10-07 23:43:08 +03:00
-- We intentionally avoid using a constructor to ensure the constructor doesn't
-- affect type resolution.
useAmbiguousType : AmbiguousType -> ()
2021-10-07 01:56:56 +03:00
useAmbiguousType _ = ()
useUnknownType : UnknownType -> ()
useUnknownType _ = ()
2021-10-07 23:43:08 +03:00
-- Despite being a duplicate disambiguation, this should still be included in the annotations printout
separateAmbiguousTypeUsage : AmbiguousType -> ()
separateAmbiguousTypeUsage _ = ()
```
Currently, ambiguous terms are caught and handled by type directed name resolution,
but expect it to eventually be handled by the above machinery.
```unison:error
useAmbiguousTerm = ambiguousTerm
2021-10-07 01:56:56 +03:00
```