Skip to content

Commit 0469dff

Browse files
committed
Runtime: raise constant (close #325)
1 parent 8cc8631 commit 0469dff

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

runtime/stdlib.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ function caml_raise_constant (tag) { throw [0, tag]; }
113113
//Version: >= 4.02
114114
function caml_raise_constant (tag) { throw tag; }
115115

116+
//Provides: caml_return_exn_constant (const)
117+
//Version: < 4.02
118+
function caml_return_exn_constant (tag) { return [0, tag]; }
119+
120+
//Provides: caml_return_exn_constant (const)
121+
//Version: >= 4.02
122+
function caml_return_exn_constant (tag) { return tag; }
123+
116124
//Provides: caml_raise_with_arg (const, const)
117125
function caml_raise_with_arg (tag, arg) { throw [0, tag, arg]; }
118126

@@ -133,22 +141,24 @@ function caml_raise_sys_error (msg) {
133141
function caml_failwith (msg) {
134142
caml_raise_with_string(caml_global_data.Failure, msg);
135143
}
144+
136145
//Provides: caml_wrap_exception const (const)
137146
//Requires: caml_global_data,caml_js_to_string,caml_named_value
147+
//Requires: caml_return_exn_constant
138148
function caml_wrap_exception(e) {
139149
if(e instanceof Array) return e;
140150
//Stack_overflow: chrome, safari
141151
if(joo_global_object.RangeError
142152
&& e instanceof joo_global_object.RangeError
143153
&& e.message
144154
&& e.message.match(/maximum call stack/i))
145-
return [0,caml_global_data.Stack_overflow];
155+
return caml_return_exn_constant(caml_global_data.Stack_overflow);
146156
//Stack_overflow: firefox
147157
if(joo_global_object.InternalError
148158
&& e instanceof joo_global_object.InternalError
149159
&& e.message
150160
&& e.message.match(/too much recursion/i))
151-
return [0,caml_global_data.Stack_overflow];
161+
return caml_return_exn_constant(caml_global_data.Stack_overflow);
152162
//Wrap Error in Js.Error exception
153163
if(e instanceof joo_global_object.Error)
154164
return [0,caml_named_value("jsError"),e];

0 commit comments

Comments
 (0)