This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree 2 files changed +7
-13
lines changed
tests/parsing/errors/other/__snapshots__
2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -1600,10 +1600,6 @@ and parseParameter p =
1600
1600
let lidents = parseLidentList p in
1601
1601
Some (TypeParameter {uncurried; attrs; locs = lidents; pos = startPos})
1602
1602
) else (
1603
- let hasTilde = match p.token with
1604
- | Tilde -> true
1605
- | _ -> false
1606
- in
1607
1603
let (attrs, lbl, pat) = match p.Parser. token with
1608
1604
| Tilde ->
1609
1605
Parser. next p;
@@ -1650,16 +1646,14 @@ and parseParameter p =
1650
1646
in
1651
1647
match p.Parser. token with
1652
1648
| Equal ->
1653
- if not hasTilde then (
1654
- let msg = match pat.ppat_desc with
1655
- | Ppat_var var -> ErrorMessages. missingTildeLabeledParameter var.txt
1656
- | _ -> ErrorMessages. missingTildeLabeledParameter " "
1657
- in
1658
- Parser. err ~start Pos p (Diagnostics. message msg)
1659
- );
1660
1649
Parser. next p;
1661
1650
let lbl = match lbl with
1662
- | Asttypes. Labelled lblName ->
1651
+ | Asttypes. Labelled lblName -> Asttypes. Optional lblName
1652
+ | Asttypes. Nolabel ->
1653
+ let lblName = match pat.ppat_desc with | Ppat_var var -> var.txt | _ -> " " in
1654
+ Parser. err ~start Pos ~end Pos:p.prevEndPos p (
1655
+ Diagnostics. message (ErrorMessages. missingTildeLabeledParameter lblName)
1656
+ );
1663
1657
Asttypes. Optional lblName
1664
1658
| lbl -> lbl
1665
1659
in
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ module M = struct ;;match l with | None -> [] | Some l -> l ## prop end
37
37
38
38
exports [` labelledParameters.res 1` ] = `
39
39
"=====Parsetree==========================================
40
- let f x y z = (x + y) + z
40
+ let f x ?(y= 2) z = (x + y) + z
41
41
type nonrec f = x:int -> y:int -> int
42
42
=====Errors=============================================
43
43
You can’t perform that action at this time.
0 commit comments