diff --git a/src/context_free.ml b/src/context_free.ml index 99270e16..09f58501 100644 --- a/src/context_free.ml +++ b/src/context_free.ml @@ -567,7 +567,8 @@ class map_top_down ?(expect_mismatch_handler = Expect_mismatch_handler.nop) | Some pattern -> ( let generated_code = try return (pattern e) - with exn when embed_errors -> (None, [ exn_to_loc_error exn ]) + with exn when embed_errors -> + return (Some (exn_to_error_extension EC.expression e exn)) in generated_code >>= fun expr -> match expr with @@ -581,7 +582,8 @@ class map_top_down ?(expect_mismatch_handler = Expect_mismatch_handler.nop) | Some pattern -> ( let generated_code = try return (pattern e) - with exn when embed_errors -> (None, [ exn_to_loc_error exn ]) + with exn when embed_errors -> + return (Some (exn_to_error_extension EC.expression e exn)) in generated_code >>= fun expr -> match expr with @@ -589,10 +591,12 @@ class map_top_down ?(expect_mismatch_handler = Expect_mismatch_handler.nop) | Some e -> self#expression base_ctxt e)) | Pexp_constant (Pconst_integer (s, Some c)) -> ( try expand_constant Integer c s - with exn when embed_errors -> (e, [ exn_to_loc_error exn ])) + with exn when embed_errors -> + return (exn_to_error_extension EC.expression e exn)) | Pexp_constant (Pconst_float (s, Some c)) -> ( try expand_constant Float c s - with exn when embed_errors -> (e, [ exn_to_loc_error exn ])) + with exn when embed_errors -> + return (exn_to_error_extension EC.expression e exn)) | _ -> super#expression base_ctxt e (* Pre-conditions: diff --git a/test/driver/exception_handling/run.t b/test/driver/exception_handling/run.t index c368f950..3fc684ec 100644 --- a/test/driver/exception_handling/run.t +++ b/test/driver/exception_handling/run.t @@ -171,16 +171,18 @@ when the -embed-errors flag is not passed When embed-errors is not passed $ ./constant_type.exe -embed-errors impl.ml - [%%ocaml.error - "A raised located error in the constant rewriting transformation."] - [%%ocaml.error - "A raised located error in the constant rewriting transformation."] - [%%ocaml.error - "A raised located error in the constant rewriting transformation."] - [%%ocaml.error - "A raised located error in the constant rewriting transformation."] - let x = 2g + 3g - let x = 2g + 3g + let x = + ([%ocaml.error + "A raised located error in the constant rewriting transformation."]) + + + ([%ocaml.error + "A raised located error in the constant rewriting transformation."]) + let x = + ([%ocaml.error + "A raised located error in the constant rewriting transformation."]) + + + ([%ocaml.error + "A raised located error in the constant rewriting transformation."]) In the case of Special functions @@ -194,10 +196,8 @@ when the -embed-errors flag is not passed When embed-errors is not passed $ ./special_functions.exe -embed-errors impl.ml - [%%ocaml.error "error special function"] - [%%ocaml.error "second error special function"] - let x1 = n_args - let x2 = n_args2 + let x1 = [%ocaml.error "error special function"] + let x2 = [%ocaml.error "second error special function"] In the case of whole file transformations: