Skip to content

Commit

Permalink
Show "proper" error message in Context.parse* functions when invalid …
Browse files Browse the repository at this point in the history
…expressions are passed.
  • Loading branch information
nadako committed May 20, 2014
1 parent b51e564 commit 3b7f08f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion interp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,8 @@ let macro_lib =
);
"parse", Fun3 (fun s p b ->
match s, p, b with
| VString s, VAbstract (APos p), VBool b when s <> "" -> encode_expr ((get_ctx()).curapi.parse_string s p b)
| VString s, VAbstract (APos p), VBool b when s <> "" ->
(try encode_expr ((get_ctx()).curapi.parse_string s p b) with Invalid_expr -> error())
| _ -> error()
);
"make_expr", Fun2 (fun v p ->
Expand Down
2 changes: 1 addition & 1 deletion typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ let parse_expr_string ctx s p inl =
let rec loop e = let e = Ast.map_expr loop e in (fst e,p) in
match parse_string ctx (head ^ s ^ ";}") p inl with
| EClass { d_data = [{ cff_name = "main"; cff_kind = FFun { f_expr = Some e } }]} -> if inl then e else loop e
| _ -> assert false
| _ -> raise Interp.Invalid_expr

let collect_toplevel_identifiers ctx =
let acc = DynArray.create () in
Expand Down

0 comments on commit 3b7f08f

Please sign in to comment.