|
| 1 | +(* TEST_BELOW |
| 2 | +Fille |
| 3 | +*) |
| 4 | + |
| 5 | +let f = fun ~(call_pos:[%call_pos]) () -> call_pos |
| 6 | +[%%expect {| |
| 7 | +val f : call_pos:[%call_pos] -> unit -> lexing_position = <fun> |
| 8 | +|}] |
| 9 | + |
| 10 | +let _ = f ?call_pos:None (); |
| 11 | +[%%expect {| |
| 12 | +Line 1, characters 20-24: |
| 13 | +1 | let _ = f ?call_pos:None (); |
| 14 | + ^^^^ |
| 15 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 16 | + automatically if ommitted. It cannot be passed with '?'. |
| 17 | +|}] |
| 18 | + |
| 19 | +let _ = |
| 20 | + let pos = f () in |
| 21 | + f ?call_pos:(Some pos) (); |
| 22 | +[%%expect {| |
| 23 | +Line 3, characters 14-24: |
| 24 | +3 | f ?call_pos:(Some pos) (); |
| 25 | + ^^^^^^^^^^ |
| 26 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 27 | + automatically if ommitted. It cannot be passed with '?'. |
| 28 | +|}] |
| 29 | + |
| 30 | +let ( >>| ) ~(call_pos : [%call_pos]) a b = a + b, call_pos ;; |
| 31 | +[%%expect {| |
| 32 | +val ( >>| ) : call_pos:[%call_pos] -> int -> int -> int * lexing_position = |
| 33 | + <fun> |
| 34 | +|}] |
| 35 | + |
| 36 | +let _ = ( >>| ) ?call_pos:None 1 2 ;; |
| 37 | +[%%expect {| |
| 38 | +Line 1, characters 27-31: |
| 39 | +1 | let _ = ( >>| ) ?call_pos:None 1 2 ;; |
| 40 | + ^^^^ |
| 41 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 42 | + automatically if ommitted. It cannot be passed with '?'. |
| 43 | +|}] |
| 44 | + |
| 45 | +let _ = |
| 46 | + let pos = f () in |
| 47 | + ( >>| ) ?call_pos:(Some pos) 1 2 |
| 48 | +;; |
| 49 | +[%%expect {| |
| 50 | +Line 3, characters 20-30: |
| 51 | +3 | ( >>| ) ?call_pos:(Some pos) 1 2 |
| 52 | + ^^^^^^^^^^ |
| 53 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 54 | + automatically if ommitted. It cannot be passed with '?'. |
| 55 | +|}] |
| 56 | + |
| 57 | +class c ~(call_pos : [%call_pos]) () = object |
| 58 | + method call_pos = call_pos |
| 59 | +end |
| 60 | +[%%expect {| |
| 61 | +class c : |
| 62 | + call_pos:[%call_pos] -> |
| 63 | + unit -> object method call_pos : lexing_position end |
| 64 | +|}] |
| 65 | + |
| 66 | +let _ = (new c ?call_pos:None ())#call_pos;; |
| 67 | +[%%expect {| |
| 68 | +Line 1, characters 25-29: |
| 69 | +1 | let _ = (new c ?call_pos:None ())#call_pos;; |
| 70 | + ^^^^ |
| 71 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 72 | + automatically if ommitted. It cannot be passed with '?'. |
| 73 | +|}] |
| 74 | + |
| 75 | +let _ = |
| 76 | + let pos = f () in |
| 77 | + (new c ?call_pos:(Some pos) ())#call_pos;; |
| 78 | +[%%expect {| |
| 79 | +Line 3, characters 19-29: |
| 80 | +3 | (new c ?call_pos:(Some pos) ())#call_pos;; |
| 81 | + ^^^^^^^^^^ |
| 82 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 83 | + automatically if ommitted. It cannot be passed with '?'. |
| 84 | +|}] |
| 85 | + |
| 86 | +class parent ~(call_pos : [%call_pos]) () = object |
| 87 | + method pos = call_pos |
| 88 | +end |
| 89 | +[%%expect {| |
| 90 | +class parent : |
| 91 | + call_pos:[%call_pos] -> unit -> object method pos : lexing_position end |
| 92 | +|}] |
| 93 | + |
| 94 | +let _ = (object |
| 95 | + inherit parent ?call_pos:None () |
| 96 | +end)#pos;; |
| 97 | +[%%expect {| |
| 98 | +Line 2, characters 27-31: |
| 99 | +2 | inherit parent ?call_pos:None () |
| 100 | + ^^^^ |
| 101 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 102 | + automatically if ommitted. It cannot be passed with '?'. |
| 103 | +|}] |
| 104 | + |
| 105 | +let o = (object |
| 106 | + inherit parent ?call_pos:(Some (f ())) () |
| 107 | +end)#pos |
| 108 | +[%%expect {| |
| 109 | +Line 2, characters 27-40: |
| 110 | +2 | inherit parent ?call_pos:(Some (f ())) () |
| 111 | + ^^^^^^^^^^^^^ |
| 112 | +Error: the argument labeled 'call_pos' is a [%call_pos] argument, filled in |
| 113 | + automatically if ommitted. It cannot be passed with '?'. |
| 114 | +|}] |
| 115 | + |
| 116 | + |
| 117 | +(* TEST |
| 118 | + expect; |
| 119 | +*) |
0 commit comments