sanctuary-js / sanctuary-def

Run-time type system for JavaScript
MIT License
294 stars 23 forks source link

imprecise underlining upon function argument returning invalid value #181

Closed davidchambers closed 6 years ago

davidchambers commented 6 years ago

If the return value of a function argument is incorrect, the entire return type is underlined even if the outermost type is correct. For example:

S.unfoldr (c => c <= 'z' ? S.Just (c) : S.Nothing) ('a');
// ! TypeError: Invalid value
//
//   unfoldr :: (b -> Maybe (Pair a b)) -> b -> Array a
//                    ^^^^^^^^^^^^^^^^
//                           1
//
//   1)  Just("a") :: Maybe String
//
//   The value at position 1 is not a member of ‘Maybe (Pair a b)’.
//
//   See https://github.com/sanctuary-js/sanctuary/tree/v0.14.1#MaybeType for information about the sanctuary/Maybe type.

Only Pair a b should be underlined in this case.