Skip to content

Commit

Permalink
improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongbo Zhang committed Aug 9, 2016
1 parent f4b7e5f commit 4412f8e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
21 changes: 14 additions & 7 deletions jscomp/syntax/ast_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,10 @@ let ocaml_obj_as_js_object
Cfk_concrete
(Fresh, e))
->
begin match e with
| {
pexp_desc =
Pexp_poly
(({pexp_desc = Pexp_fun ("", None, pat, e)} as f),
None)} ->
begin match e.pexp_desc with
| Pexp_poly
(({pexp_desc = Pexp_fun ("", None, pat, e)} as f),
None) ->
let arity = Ast_pat.arity_of_fun pat e in
let method_type, label_type =
generate_callback_method_pair x.pcf_loc mapper label.txt arity in
Expand All @@ -433,9 +431,18 @@ let ocaml_obj_as_js_object
let f = Ast_pat.is_unit_cont pat ~yes:e ~no:f in
to_method_callback loc mapper self_pat f
} :: exprs)
| Pexp_poly( _, Some _)
->
Location.raise_errorf ~loc:x.pcf_loc
"polymorphic type annotation not supported yet"

| Pexp_poly (_, None) ->
Location.raise_errorf
~loc:x.pcf_loc
"Unsupported syntax, expect syntax like `method x () = x ` "
| _ ->
Location.raise_errorf ~loc:x.pcf_loc
"polymorphic type annotation not supported"
"Unsupported syntax in js object"
end
| Pcf_method (_, _, Cfk_concrete(Override, _) ) ->
Location.raise_errorf ~loc:x.pcf_loc
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/ppx_this_obj_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ var collection = /* array */[
v4
];

eq('File "ppx_this_obj_test.ml", line 55, characters 5-12', /* tuple */[
eq('File "ppx_this_obj_test.ml", line 59, characters 5-12', /* tuple */[
11,
v.hi(3, 2)
]);

eq('File "ppx_this_obj_test.ml", line 56, characters 5-12', /* tuple */[
eq('File "ppx_this_obj_test.ml", line 60, characters 5-12', /* tuple */[
11,
v2.hi(3, 2)
]);
Expand Down
6 changes: 5 additions & 1 deletion jscomp/test/ppx_this_obj_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ let v4 =
method x () = 1.
end [@bs]


(* let v5 = *)
(* object *)
(* method x = x *)
(* end [@bs] *)

(** guarantee they have the same type *)
let collection = [| v ; v2 ; v3 ; v4 |]

Expand Down

0 comments on commit 4412f8e

Please sign in to comment.