|
| 1 | +(* TEST |
| 2 | + * expect |
| 3 | +*) |
| 4 | + |
| 5 | +(* A bug in typecore leading to extra expansion led this to be rejected. *) |
| 6 | + |
| 7 | +type (_, _) refl = Refl : ('a, 'a) refl |
| 8 | + |
| 9 | +[%%expect{| |
| 10 | +type (_, _) refl = Refl : ('a, 'a) refl |
| 11 | +|}] |
| 12 | + |
| 13 | +let apply (_ : unit -> 'a) : 'a = assert false |
| 14 | +let go (type a) (Refl : (unit, a) refl) = apply (fun () : a -> ()) |
| 15 | + |
| 16 | +[%%expect{| |
| 17 | +val apply : (unit -> 'a) -> 'a = <fun> |
| 18 | +val go : (unit, 'a) refl -> 'a = <fun> |
| 19 | +|}] |
| 20 | + |
| 21 | +let apply (_ : x:unit -> unit -> 'a) : 'a = assert false |
| 22 | +let go (type a) (Refl : (unit, a) refl) = apply (fun ~x:_ () : a -> ()) |
| 23 | + |
| 24 | +[%%expect{| |
| 25 | +val apply : (x:unit -> unit -> 'a) -> 'a = <fun> |
| 26 | +val go : (unit, 'a) refl -> 'a = <fun> |
| 27 | +|}] |
| 28 | + |
| 29 | +let apply (_ : ?x:unit -> unit -> 'a) : 'a = assert false |
| 30 | +let go (type a) (Refl : (unit, a) refl) = apply (fun ?x:_ () : a -> ()) |
| 31 | + |
| 32 | +[%%expect{| |
| 33 | +val apply : (?x:unit -> unit -> 'a) -> 'a = <fun> |
| 34 | +Line 2, characters 42-71: |
| 35 | +2 | let go (type a) (Refl : (unit, a) refl) = apply (fun ?x:_ () : a -> ()) |
| 36 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 37 | +Error: This expression has type a = unit |
| 38 | + but an expression was expected of type 'a |
| 39 | + This instance of unit is ambiguous: |
| 40 | + it would escape the scope of its equation |
| 41 | +|}] |
| 42 | + |
| 43 | +let apply (_ : unit -> x:unit -> 'a) : 'a = assert false |
| 44 | +let go (type a) (Refl : (unit, a) refl) = apply (fun () ~x:_ : a -> ()) |
| 45 | + |
| 46 | +[%%expect{| |
| 47 | +val apply : (unit -> x:unit -> 'a) -> 'a = <fun> |
| 48 | +val go : (unit, 'a) refl -> 'a = <fun> |
| 49 | +|}] |
| 50 | + |
| 51 | +let apply (_ : unit -> ?x:unit -> 'a) : 'a = assert false |
| 52 | +let go (type a) (Refl : (unit, a) refl) = apply (fun () ?x:_ : a -> ()) |
| 53 | + |
| 54 | +[%%expect{| |
| 55 | +val apply : (unit -> ?x:unit -> 'a) -> 'a = <fun> |
| 56 | +Line 2, characters 59-60: |
| 57 | +2 | let go (type a) (Refl : (unit, a) refl) = apply (fun () ?x:_ : a -> ()) |
| 58 | + ^ |
| 59 | +Warning 16 [unerasable-optional-argument]: this optional argument cannot be erased. |
| 60 | + |
| 61 | +Line 2, characters 42-71: |
| 62 | +2 | let go (type a) (Refl : (unit, a) refl) = apply (fun () ?x:_ : a -> ()) |
| 63 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 64 | +Error: This expression has type a = unit |
| 65 | + but an expression was expected of type 'a |
| 66 | + This instance of unit is ambiguous: |
| 67 | + it would escape the scope of its equation |
| 68 | +|}] |
0 commit comments