Skip to content

Commit fac8dec

Browse files
authored
Merge pull request #4388 from chenglou/jsx
[JSX] Fix unused patterns warnings that causes build failure
2 parents dff9315 + a3af4d9 commit fac8dec

File tree

4 files changed

+69
-45
lines changed

4 files changed

+69
-45
lines changed

jscomp/syntax/reactjs_jsx_ppx.cppo.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ let jsxMapper () =
534534
| Ptyp_constr({txt}, _innerTypeArgs) -> String.concat "." (Longident.flatten txt) ^ "(...)"
535535
| _ -> "...")
536536
in
537-
Location.prerr_warning pattern.ppat_loc
538-
(Preprocessor
537+
Location.prerr_warning pattern.ppat_loc
538+
(Preprocessor
539539
(Printf.sprintf "ReasonReact: optional argument annotations must have explicit `option`. Did you mean `option(%s)=?`?" currentType)))
540540
| _ -> ()) in
541541
let alias = (match pattern with
@@ -716,7 +716,7 @@ let jsxMapper () =
716716
} -> ((fun a -> a), false, unerasableIgnoreExp expression)
717717
(* let make = (prop) => ... *)
718718
| {
719-
pexp_desc = Pexp_fun (nolabel, default, pattern, internalExpression)
719+
pexp_desc = Pexp_fun (_nolabel, _default, _pattern, _internalExpression)
720720
} -> raise (Invalid_argument "if your component doesn't take any props use () or _ instead of a name as your argument")
721721
(* let make = {let foo = bar in (~prop) => ...} *)
722722
| {

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -410205,8 +410205,8 @@ let jsxMapper () =
410205410205
| Ptyp_constr({txt}, _innerTypeArgs) -> String.concat "." (Longident.flatten txt) ^ "(...)"
410206410206
| _ -> "...")
410207410207
in
410208-
Location.prerr_warning pattern.ppat_loc
410209-
(Preprocessor
410208+
Location.prerr_warning pattern.ppat_loc
410209+
(Preprocessor
410210410210
(Printf.sprintf "ReasonReact: optional argument annotations must have explicit `option`. Did you mean `option(%s)=?`?" currentType)))
410211410211
| _ -> ()) in
410212410212
let alias = (match pattern with
@@ -410383,8 +410383,12 @@ let jsxMapper () =
410383410383
} -> ((fun a -> a), true, expression)
410384410384
(* let make = (~prop) => ... *)
410385410385
| {
410386-
pexp_desc = Pexp_fun (_label, _default, _pattern, _internalExpression)
410386+
pexp_desc = Pexp_fun ((Labelled(_) | Optional(_)), _default, _pattern, _internalExpression)
410387410387
} -> ((fun a -> a), false, unerasableIgnoreExp expression)
410388+
(* let make = (prop) => ... *)
410389+
| {
410390+
pexp_desc = Pexp_fun (_nolabel, _default, _pattern, _internalExpression)
410391+
} -> raise (Invalid_argument "if your component doesn't take any props use () or _ instead of a name as your argument")
410388410392
(* let make = {let foo = bar in (~prop) => ...} *)
410389410393
| {
410390410394
pexp_desc = Pexp_let (recursive, vbs, internalExpression)
@@ -410597,11 +410601,11 @@ let jsxMapper () =
410597410601
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
410598410602
(match !jsxVersion with
410599410603

410600-
# 929 "syntax/reactjs_jsx_ppx.cppo.ml"
410604+
# 933 "syntax/reactjs_jsx_ppx.cppo.ml"
410601410605
| None
410602410606
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
410603410607

410604-
# 935 "syntax/reactjs_jsx_ppx.cppo.ml"
410608+
# 939 "syntax/reactjs_jsx_ppx.cppo.ml"
410605410609
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
410606410610
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
410607410611

@@ -410611,11 +410615,11 @@ let jsxMapper () =
410611410615
| {loc; txt = Lident id} ->
410612410616
(match !jsxVersion with
410613410617

410614-
# 944 "syntax/reactjs_jsx_ppx.cppo.ml"
410618+
# 948 "syntax/reactjs_jsx_ppx.cppo.ml"
410615410619
| None
410616410620
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
410617410621

410618-
# 950 "syntax/reactjs_jsx_ppx.cppo.ml"
410622+
# 954 "syntax/reactjs_jsx_ppx.cppo.ml"
410619410623
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
410620410624
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
410621410625

@@ -411253,8 +411257,8 @@ let jsxMapper () =
411253411257
| Ptyp_constr({txt}, _innerTypeArgs) -> String.concat "." (Longident.flatten txt) ^ "(...)"
411254411258
| _ -> "...")
411255411259
in
411256-
Location.prerr_warning pattern.ppat_loc
411257-
(Preprocessor
411260+
Location.prerr_warning pattern.ppat_loc
411261+
(Preprocessor
411258411262
(Printf.sprintf "ReasonReact: optional argument annotations must have explicit `option`. Did you mean `option(%s)=?`?" currentType)))
411259411263
| _ -> ()) in
411260411264
let alias = (match pattern with
@@ -411431,8 +411435,12 @@ let jsxMapper () =
411431411435
} -> ((fun a -> a), true, expression)
411432411436
(* let make = (~prop) => ... *)
411433411437
| {
411434-
pexp_desc = Pexp_fun (_label, _default, _pattern, _internalExpression)
411438+
pexp_desc = Pexp_fun ((Labelled(_) | Optional(_)), _default, _pattern, _internalExpression)
411435411439
} -> ((fun a -> a), false, unerasableIgnoreExp expression)
411440+
(* let make = (prop) => ... *)
411441+
| {
411442+
pexp_desc = Pexp_fun (_nolabel, _default, _pattern, _internalExpression)
411443+
} -> raise (Invalid_argument "if your component doesn't take any props use () or _ instead of a name as your argument")
411436411444
(* let make = {let foo = bar in (~prop) => ...} *)
411437411445
| {
411438411446
pexp_desc = Pexp_let (recursive, vbs, internalExpression)
@@ -411645,11 +411653,11 @@ let jsxMapper () =
411645411653
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
411646411654
(match !jsxVersion with
411647411655

411648-
# 932 "syntax/reactjs_jsx_ppx.cppo.ml"
411656+
# 936 "syntax/reactjs_jsx_ppx.cppo.ml"
411649411657
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
411650411658
| None
411651411659

411652-
# 935 "syntax/reactjs_jsx_ppx.cppo.ml"
411660+
# 939 "syntax/reactjs_jsx_ppx.cppo.ml"
411653411661
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
411654411662
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
411655411663

@@ -411659,11 +411667,11 @@ let jsxMapper () =
411659411667
| {loc; txt = Lident id} ->
411660411668
(match !jsxVersion with
411661411669

411662-
# 947 "syntax/reactjs_jsx_ppx.cppo.ml"
411670+
# 951 "syntax/reactjs_jsx_ppx.cppo.ml"
411663411671
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
411664411672
| None
411665411673

411666-
# 950 "syntax/reactjs_jsx_ppx.cppo.ml"
411674+
# 954 "syntax/reactjs_jsx_ppx.cppo.ml"
411667411675
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
411668411676
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
411669411677

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -410097,8 +410097,8 @@ let jsxMapper () =
410097410097
| Ptyp_constr({txt}, _innerTypeArgs) -> String.concat "." (Longident.flatten txt) ^ "(...)"
410098410098
| _ -> "...")
410099410099
in
410100-
Location.prerr_warning pattern.ppat_loc
410101-
(Preprocessor
410100+
Location.prerr_warning pattern.ppat_loc
410101+
(Preprocessor
410102410102
(Printf.sprintf "ReasonReact: optional argument annotations must have explicit `option`. Did you mean `option(%s)=?`?" currentType)))
410103410103
| _ -> ()) in
410104410104
let alias = (match pattern with
@@ -410275,8 +410275,12 @@ let jsxMapper () =
410275410275
} -> ((fun a -> a), true, expression)
410276410276
(* let make = (~prop) => ... *)
410277410277
| {
410278-
pexp_desc = Pexp_fun (_label, _default, _pattern, _internalExpression)
410278+
pexp_desc = Pexp_fun ((Labelled(_) | Optional(_)), _default, _pattern, _internalExpression)
410279410279
} -> ((fun a -> a), false, unerasableIgnoreExp expression)
410280+
(* let make = (prop) => ... *)
410281+
| {
410282+
pexp_desc = Pexp_fun (_nolabel, _default, _pattern, _internalExpression)
410283+
} -> raise (Invalid_argument "if your component doesn't take any props use () or _ instead of a name as your argument")
410280410284
(* let make = {let foo = bar in (~prop) => ...} *)
410281410285
| {
410282410286
pexp_desc = Pexp_let (recursive, vbs, internalExpression)
@@ -410489,11 +410493,11 @@ let jsxMapper () =
410489410493
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
410490410494
(match !jsxVersion with
410491410495

410492-
# 929 "syntax/reactjs_jsx_ppx.cppo.ml"
410496+
# 933 "syntax/reactjs_jsx_ppx.cppo.ml"
410493410497
| None
410494410498
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
410495410499

410496-
# 935 "syntax/reactjs_jsx_ppx.cppo.ml"
410500+
# 939 "syntax/reactjs_jsx_ppx.cppo.ml"
410497410501
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
410498410502
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
410499410503

@@ -410503,11 +410507,11 @@ let jsxMapper () =
410503410507
| {loc; txt = Lident id} ->
410504410508
(match !jsxVersion with
410505410509

410506-
# 944 "syntax/reactjs_jsx_ppx.cppo.ml"
410510+
# 948 "syntax/reactjs_jsx_ppx.cppo.ml"
410507410511
| None
410508410512
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
410509410513

410510-
# 950 "syntax/reactjs_jsx_ppx.cppo.ml"
410514+
# 954 "syntax/reactjs_jsx_ppx.cppo.ml"
410511410515
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
410512410516
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
410513410517

@@ -411145,8 +411149,8 @@ let jsxMapper () =
411145411149
| Ptyp_constr({txt}, _innerTypeArgs) -> String.concat "." (Longident.flatten txt) ^ "(...)"
411146411150
| _ -> "...")
411147411151
in
411148-
Location.prerr_warning pattern.ppat_loc
411149-
(Preprocessor
411152+
Location.prerr_warning pattern.ppat_loc
411153+
(Preprocessor
411150411154
(Printf.sprintf "ReasonReact: optional argument annotations must have explicit `option`. Did you mean `option(%s)=?`?" currentType)))
411151411155
| _ -> ()) in
411152411156
let alias = (match pattern with
@@ -411323,8 +411327,12 @@ let jsxMapper () =
411323411327
} -> ((fun a -> a), true, expression)
411324411328
(* let make = (~prop) => ... *)
411325411329
| {
411326-
pexp_desc = Pexp_fun (_label, _default, _pattern, _internalExpression)
411330+
pexp_desc = Pexp_fun ((Labelled(_) | Optional(_)), _default, _pattern, _internalExpression)
411327411331
} -> ((fun a -> a), false, unerasableIgnoreExp expression)
411332+
(* let make = (prop) => ... *)
411333+
| {
411334+
pexp_desc = Pexp_fun (_nolabel, _default, _pattern, _internalExpression)
411335+
} -> raise (Invalid_argument "if your component doesn't take any props use () or _ instead of a name as your argument")
411328411336
(* let make = {let foo = bar in (~prop) => ...} *)
411329411337
| {
411330411338
pexp_desc = Pexp_let (recursive, vbs, internalExpression)
@@ -411537,11 +411545,11 @@ let jsxMapper () =
411537411545
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
411538411546
(match !jsxVersion with
411539411547

411540-
# 932 "syntax/reactjs_jsx_ppx.cppo.ml"
411548+
# 936 "syntax/reactjs_jsx_ppx.cppo.ml"
411541411549
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
411542411550
| None
411543411551

411544-
# 935 "syntax/reactjs_jsx_ppx.cppo.ml"
411552+
# 939 "syntax/reactjs_jsx_ppx.cppo.ml"
411545411553
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
411546411554
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
411547411555

@@ -411551,11 +411559,11 @@ let jsxMapper () =
411551411559
| {loc; txt = Lident id} ->
411552411560
(match !jsxVersion with
411553411561

411554-
# 947 "syntax/reactjs_jsx_ppx.cppo.ml"
411562+
# 951 "syntax/reactjs_jsx_ppx.cppo.ml"
411555411563
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
411556411564
| None
411557411565

411558-
# 950 "syntax/reactjs_jsx_ppx.cppo.ml"
411566+
# 954 "syntax/reactjs_jsx_ppx.cppo.ml"
411559411567
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
411560411568
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
411561411569

lib/4.06.1/whole_compiler.ml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -413944,8 +413944,8 @@ let jsxMapper () =
413944413944
| Ptyp_constr({txt}, _innerTypeArgs) -> String.concat "." (Longident.flatten txt) ^ "(...)"
413945413945
| _ -> "...")
413946413946
in
413947-
Location.prerr_warning pattern.ppat_loc
413948-
(Preprocessor
413947+
Location.prerr_warning pattern.ppat_loc
413948+
(Preprocessor
413949413949
(Printf.sprintf "ReasonReact: optional argument annotations must have explicit `option`. Did you mean `option(%s)=?`?" currentType)))
413950413950
| _ -> ()) in
413951413951
let alias = (match pattern with
@@ -414122,8 +414122,12 @@ let jsxMapper () =
414122414122
} -> ((fun a -> a), true, expression)
414123414123
(* let make = (~prop) => ... *)
414124414124
| {
414125-
pexp_desc = Pexp_fun (_label, _default, _pattern, _internalExpression)
414125+
pexp_desc = Pexp_fun ((Labelled(_) | Optional(_)), _default, _pattern, _internalExpression)
414126414126
} -> ((fun a -> a), false, unerasableIgnoreExp expression)
414127+
(* let make = (prop) => ... *)
414128+
| {
414129+
pexp_desc = Pexp_fun (_nolabel, _default, _pattern, _internalExpression)
414130+
} -> raise (Invalid_argument "if your component doesn't take any props use () or _ instead of a name as your argument")
414127414131
(* let make = {let foo = bar in (~prop) => ...} *)
414128414132
| {
414129414133
pexp_desc = Pexp_let (recursive, vbs, internalExpression)
@@ -414336,11 +414340,11 @@ let jsxMapper () =
414336414340
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
414337414341
(match !jsxVersion with
414338414342

414339-
# 929 "syntax/reactjs_jsx_ppx.cppo.ml"
414343+
# 933 "syntax/reactjs_jsx_ppx.cppo.ml"
414340414344
| None
414341414345
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
414342414346

414343-
# 935 "syntax/reactjs_jsx_ppx.cppo.ml"
414347+
# 939 "syntax/reactjs_jsx_ppx.cppo.ml"
414344414348
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
414345414349
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
414346414350

@@ -414350,11 +414354,11 @@ let jsxMapper () =
414350414354
| {loc; txt = Lident id} ->
414351414355
(match !jsxVersion with
414352414356

414353-
# 944 "syntax/reactjs_jsx_ppx.cppo.ml"
414357+
# 948 "syntax/reactjs_jsx_ppx.cppo.ml"
414354414358
| None
414355414359
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
414356414360

414357-
# 950 "syntax/reactjs_jsx_ppx.cppo.ml"
414361+
# 954 "syntax/reactjs_jsx_ppx.cppo.ml"
414358414362
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
414359414363
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
414360414364

@@ -414992,8 +414996,8 @@ let jsxMapper () =
414992414996
| Ptyp_constr({txt}, _innerTypeArgs) -> String.concat "." (Longident.flatten txt) ^ "(...)"
414993414997
| _ -> "...")
414994414998
in
414995-
Location.prerr_warning pattern.ppat_loc
414996-
(Preprocessor
414999+
Location.prerr_warning pattern.ppat_loc
415000+
(Preprocessor
414997415001
(Printf.sprintf "ReasonReact: optional argument annotations must have explicit `option`. Did you mean `option(%s)=?`?" currentType)))
414998415002
| _ -> ()) in
414999415003
let alias = (match pattern with
@@ -415170,8 +415174,12 @@ let jsxMapper () =
415170415174
} -> ((fun a -> a), true, expression)
415171415175
(* let make = (~prop) => ... *)
415172415176
| {
415173-
pexp_desc = Pexp_fun (_label, _default, _pattern, _internalExpression)
415177+
pexp_desc = Pexp_fun ((Labelled(_) | Optional(_)), _default, _pattern, _internalExpression)
415174415178
} -> ((fun a -> a), false, unerasableIgnoreExp expression)
415179+
(* let make = (prop) => ... *)
415180+
| {
415181+
pexp_desc = Pexp_fun (_nolabel, _default, _pattern, _internalExpression)
415182+
} -> raise (Invalid_argument "if your component doesn't take any props use () or _ instead of a name as your argument")
415175415183
(* let make = {let foo = bar in (~prop) => ...} *)
415176415184
| {
415177415185
pexp_desc = Pexp_let (recursive, vbs, internalExpression)
@@ -415384,11 +415392,11 @@ let jsxMapper () =
415384415392
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
415385415393
(match !jsxVersion with
415386415394

415387-
# 932 "syntax/reactjs_jsx_ppx.cppo.ml"
415395+
# 936 "syntax/reactjs_jsx_ppx.cppo.ml"
415388415396
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
415389415397
| None
415390415398

415391-
# 935 "syntax/reactjs_jsx_ppx.cppo.ml"
415399+
# 939 "syntax/reactjs_jsx_ppx.cppo.ml"
415392415400
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
415393415401
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
415394415402

@@ -415398,11 +415406,11 @@ let jsxMapper () =
415398415406
| {loc; txt = Lident id} ->
415399415407
(match !jsxVersion with
415400415408

415401-
# 947 "syntax/reactjs_jsx_ppx.cppo.ml"
415409+
# 951 "syntax/reactjs_jsx_ppx.cppo.ml"
415402415410
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
415403415411
| None
415404415412

415405-
# 950 "syntax/reactjs_jsx_ppx.cppo.ml"
415413+
# 954 "syntax/reactjs_jsx_ppx.cppo.ml"
415406415414
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
415407415415
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
415408415416

0 commit comments

Comments
 (0)