reasonml/reason-native

refmterr "not general enough" errors. [Good First Task!]

Opened this issue · 3 comments

We need to add a regex to extract and print these errors: Here's a repro that isn't pretty printed.

  type selector('inOut) = ('input, 'output => unit) => unit
  constraint 'inOut = 'input => 'output;
  let field =
      (
        leftSelector: selector('leftIn => 'rightOut),
        leftInput,
        rightSelector: selector('rightIn => 'rightOut),
        onDone,
      ) =>
    leftSelector(leftInput, leftResult => rightSelector(leftResult, onDone));

  type fieldComposer = {
    compose:
      'leftIn 'leftOut 'rightIn 'rightOut.
      (
        selector('leftIn => 'leftOut),
        'leftIn,
        selector('rightIn => 'rightOut),
        'rightOut => unit
      ) =>
      unit,

  }
  constraint 'leftOut = 'rightIn;
  let fieldCompose = {compose: field};

It prints:

File "lib/App.re", line 325, characters 31-36:
Error: This field value has type
         'a 'b.
           ('a -> 'b) selector ->
           'a -> ('b -> 'b) selector -> ('b -> unit) -> unit
       which is less general than
         'leftIn 'leftOut 'rightIn 'rightOut.
           ('leftIn -> 'leftOut) selector ->
           'leftIn ->
           ('rightIn -> 'rightOut) selector -> ('rightOut -> unit) -> unit

Another example that prints slightly different output but is the same issue:

  type selector('inOut) = ('input, 'output => unit) => unit
  constraint 'inOut = 'input => 'output;

  let field:
    'leftIn 'leftOut 'rightIn 'rightOut.
    (
      selector('leftIn => 'leftOut),
      'leftIn,
      selector('rightIn => 'rightOut),
      'rightOut => unit
    ) =>
    unit
   =
    (
      leftSelector: selector('leftIn => 'rightOut),
      leftInput,
      rightSelector: selector('rightIn => 'rightOut),
      onDone,
    ) =>
      /* Identity should result in: */
      leftSelector(leftInput, leftResult =>
        rightSelector(leftResult, onDone)
      );

I will try to pick that one, @jordwalke. Thanks!

Hey @jordwalke, what's the expected behaviour?

The indentation of the error or/and you mean the look the syntax (more reason-y instead of ocaml style)?

Instead of

type 'inOut selector = 'input -> ('output -> unit) -> unit

print:

type selector('inOut) = ('input, 'output => unit) => unit