Skip to content

Commit bf81f38

Browse files
committed
Fix internalize case for undefined value.
Fixes #237.
1 parent cb553f3 commit bf81f38

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

compiler/prelude/jsmapping.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ var $internalize = function(v, t, recv) {
245245
if (v === null) {
246246
return $ifaceNil;
247247
}
248+
if (v === undefined) {
249+
return new $jsObjectPtr(undefined);
250+
}
248251
switch (v.constructor) {
249252
case Int8Array:
250253
return new ($sliceType($Int8))(v);

js/js_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,16 @@ func TestUndefinedEquality(t *testing.T) {
309309
}
310310
}
311311

312+
func TestUndefinedInternalization(t *testing.T) {
313+
undefinedEqualsJsUndefined := func(i interface{}) bool {
314+
return i == js.Undefined
315+
}
316+
js.Global.Set("undefinedEqualsJsUndefined", undefinedEqualsJsUndefined)
317+
if !js.Global.Call("eval", "(undefinedEqualsJsUndefined(undefined))").Bool() {
318+
t.Fail()
319+
}
320+
}
321+
312322
func TestSameFuncWrapper(t *testing.T) {
313323
a := func(_ string) {} // string argument to force wrapping
314324
b := func(_ string) {} // string argument to force wrapping

0 commit comments

Comments
 (0)