From 74be2a09c5c628632729c619bb8c45a74abc7410 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Tue, 30 Jan 2018 21:10:33 +0800 Subject: [PATCH] quick fix for #2474 --- jscomp/core/lam_coercion.ml | 13 ++++++++++++- jscomp/test/.depend | 1 + jscomp/test/Makefile | 1 + jscomp/test/gpr_2474.js | 14 ++++++++++++++ jscomp/test/gpr_2474.ml | 6 ++++++ lib/whole_compiler.ml | 13 ++++++++++++- 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 jscomp/test/gpr_2474.js create mode 100644 jscomp/test/gpr_2474.ml diff --git a/jscomp/core/lam_coercion.ml b/jscomp/core/lam_coercion.ml index 602219ff4e..784fde5c21 100644 --- a/jscomp/core/lam_coercion.ml +++ b/jscomp/core/lam_coercion.ml @@ -210,5 +210,16 @@ let coerce_and_group_big_lambda coerced_input, {meta with export_idents = coerced_input.export_set ; exports = coerced_input.export_list} - | _ -> assert false + | _ -> + (* This could happen see #2474*) + { + export_list = []; + export_set = Ident_set.empty; + export_map = Ident_map.empty ; + (** not used in code generation, mostly used + for store some information in cmj files *) + groups = [Nop lam] ; + (* all code to be compiled later = original code + rebound coercions *) + } + , { meta with export_idents = Ident_set.empty ; exports= []} diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 502fc746c5..9366d08454 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -304,6 +304,7 @@ gpr_1943_test.cmj : mt.cmj gpr_1946_test.cmj : ../stdlib/obj.cmj ../runtime/js.cmj gpr_2250_test.cmj : mt.cmj gpr_2316_test.cmj : mt.cmj ../runtime/js.cmj +gpr_2474.cmj : gpr_405_test.cmj : ../stdlib/hashtbl.cmj gpr_405_test.cmi gpr_441.cmj : gpr_459_test.cmj : mt.cmj diff --git a/jscomp/test/Makefile b/jscomp/test/Makefile index bd14e0872c..3156bb1fa7 100644 --- a/jscomp/test/Makefile +++ b/jscomp/test/Makefile @@ -211,6 +211,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_ gpr_2316_test\ gpr_2250_test\ gpr_1285_test\ + gpr_2474\ defunctor_make_test\ bs_hashtbl_string_test\ console_log_test\ diff --git a/jscomp/test/gpr_2474.js b/jscomp/test/gpr_2474.js new file mode 100644 index 0000000000..dd5dcd994b --- /dev/null +++ b/jscomp/test/gpr_2474.js @@ -0,0 +1,14 @@ +'use strict'; + +var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js"); + +throw [ + Caml_builtin_exceptions.match_failure, + [ + "gpr_2474.ml", + 6, + 4 + ] + ]; + +/* Not a pure module */ diff --git a/jscomp/test/gpr_2474.ml b/jscomp/test/gpr_2474.ml new file mode 100644 index 0000000000..a9e7581be0 --- /dev/null +++ b/jscomp/test/gpr_2474.ml @@ -0,0 +1,6 @@ + +[@@@warning"-a"] +let coordinates = 1 + + +let 2 = coordinates \ No newline at end of file diff --git a/lib/whole_compiler.ml b/lib/whole_compiler.ml index 92e5b7982f..c0618836e2 100644 --- a/lib/whole_compiler.ml +++ b/lib/whole_compiler.ml @@ -90962,7 +90962,18 @@ let coerce_and_group_big_lambda coerced_input, {meta with export_idents = coerced_input.export_set ; exports = coerced_input.export_list} - | _ -> assert false + | _ -> + (* This could happen see #2474*) + { + export_list = []; + export_set = Ident_set.empty; + export_map = Ident_map.empty ; + (** not used in code generation, mostly used + for store some information in cmj files *) + groups = [Nop lam] ; + (* all code to be compiled later = original code + rebound coercions *) + } + , { meta with export_idents = Ident_set.empty ; exports= []} end