Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit93ca44d

Browse files
committed
don't swallow all errors maybe
1 parentcd70a90 commit93ca44d

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

‎jsx/brisk_jsx.ml‎

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ module JSX_ppx = struct
7979
end
8080

8181
moduleDeclaration_ppx=struct
82-
let func_pattern=Ppxlib.Ast_pattern.(pexp_fun __ __ __ __)
83-
84-
letmatch_pattern?on_errorlocast_node~with_=
85-
Ppxlib.Ast_pattern.parse pattern ?on_error loc ast_node with_
86-
8782
letattribute_name=function
8883
|`Component ->
8984
"component"
@@ -92,31 +87,30 @@ module Declaration_ppx = struct
9287

9388
lettransform_component_expr~useDynamicKey~attribute~component_nameexpr=
9489
letmap_component_expressionexpr=
95-
letrecloop~seenUnit ({P.pexp_loc=loc}asexpr)=
96-
try
97-
match_ func_pattern loc expr
98-
~with_:(funlblopt_argpatchild_expression ->
99-
letmake_fun_with_expr~expr=
100-
Ast_builder.pexp_fun~loc lbl opt_arg pat expr
101-
in
102-
let loc=pat.Ppxlib.ppat_locin
90+
letrecloop~seenUnit ({P.pexp_loc=loc; pexp_desc}asexpr)=
91+
match pexp_descwith
92+
|P.Pexp_fun (lbl,opt_arg,pat,child_expression) ->
93+
letmake_fun_with_expr~expr=
94+
Ast_builder.pexp_fun~loc lbl opt_arg pat expr
95+
in
96+
let loc= pat.Ppxlib.ppat_locin
97+
(match (lbl,pat)with
10398
| (Ppxlib.Optional_),_when seenUnit ->
10499
Location.raise_errorf~loc
105100
"Optional arguments not allowed after ()"
106-
| (Ppxlib.Labelled_ |Optional_),_ ->
107-
make_fun_with_expr
108-
~expr:(loop~seenUnit child_expression)
109-
|Ppxlib.Nolabel, [%pat?()] ->
110-
make_fun_with_expr
111-
~expr:(loop~seenUnit:true child_expression)
112-
|_ ->
113-
if seenUnitthen
114-
let loc= child_expression.pexp_locin
115-
[%expr [%e component_ident~loc]~key [%e make_fun_with_expr~expr:child_expression]]
116-
else
117-
Location.raise_errorf~loc
118-
"A labelled argument or () was expected")
119-
with
101+
| (Ppxlib.Labelled_ |Optional_),_ ->
102+
make_fun_with_expr
103+
~expr:(loop~seenUnit child_expression)
104+
|Ppxlib.Nolabel, [%pat?()] ->
105+
make_fun_with_expr
106+
~expr:(loop~seenUnit:true child_expression)
107+
|_ ->
108+
if seenUnitthen
109+
let loc= child_expression.pexp_locin
110+
[%expr [%e component_ident~loc]~key [%e make_fun_with_expr~expr:child_expression]]
111+
else
112+
Location.raise_errorf~loc
113+
"A labelled argument or () was expected")
120114
|_ -> [%expr [%e component_ident~loc]~key [%e expr]]
121115
in
122116
loop~seenUnit:false expr

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp