unison/unison-src/transcripts/resolution-failures.md
2024-07-02 09:48:07 -07:00

1.3 KiB

Resolution Errors

This transcript tests the errors printed to the user when a name cannot be resolved.

Codebase Setup

scratch/main> builtins.merge lib.builtins

First we define differing types with the same name in different namespaces:

unique type one.AmbiguousType = one.AmbiguousType
unique type two.AmbiguousType = two.AmbiguousType

one.ambiguousTerm = "term one"
two.ambiguousTerm = "term two"
scratch/main> add

Tests

Now we introduce code which isn't sufficiently qualified. It is ambiguous which type from which namespace we mean.

We expect the output to:

  1. Print all ambiguous usage sites separately
  2. Print possible disambiguation suggestions for each unique ambiguity
-- We intentionally avoid using a constructor to ensure the constructor doesn't
-- affect type resolution.
useAmbiguousType : AmbiguousType -> ()
useAmbiguousType _ = ()

useUnknownType : UnknownType -> ()
useUnknownType _ = ()

-- 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.

useAmbiguousTerm = ambiguousTerm