unison icon indicating copy to clipboard operation
unison copied to clipboard

Incorrect ability inference

Open etorreborre opened this issue 5 months ago • 0 comments

The following code is extracted from an experiment I was running:

type Options r = { runtime: '{r} () }

Options.override : a r -> Options r -> Options r
Options.override _a o = o

Registry.run : Options r1 -> '(a r2)-> (a {r1, r2})
Registry.run options exp = todo "run"

type Converter g
  = { convert : '{g} () }

type Logger g
  = { info : '{g} () }

type Registered a = {
  constructor: 'a,
}

logger : Registered (Logger {Store [Text]})
logger = Registered do Logger ('())

options = (Options '()) |> Options.override logger

converter = '(Registry.run options '(Converter '()))
testConverter = convert (converter()) ()

Running this code in ucm returns:

The expression in red needs the {Logger {Store [Text]}} ability, but this location does not have access to any abilities.
  
     25 | testConverter = convert (converter()) ()

The incorrect part is seeing a type being promoted to an ability in the error message.

etorreborre avatar May 18 '25 15:05 etorreborre