Skip to content

Commit d07b764

Browse files
authored
compiler: fix Make(Full)Wrapper where this is no return value (#10)
1 parent 75a0cb9 commit d07b764

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

compiler/gopherjspkg/fs_vfsdata.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/natives/fs_vfsdata.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/prelude/jsmapping.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ var $isASCII = function(s) {
392392
};
393393

394394
var $copyIfRequired = function(v, typ) {
395+
if (v == undefined) {
396+
return v;
397+
}
395398
// interface values
396399
if (v.constructor.copy) {
397400
return new v.constructor($clone(v.$val, v.constructor));

compiler/prelude/prelude.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/prelude/prelude_min.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/js_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,11 @@ func (m M) NonPointField() string {
468468
return "sensible"
469469
}
470470

471+
func (m *M) IncF() {
472+
// no return value
473+
m.f++
474+
}
475+
471476
func TestMakeWrapper(t *testing.T) {
472477
m := &M{f: 42}
473478
if !js.Global.Call("eval", `(function(m) { return m.Method({x: 1})["y"] === "z"; })`).Invoke(js.MakeWrapper(m)).Bool() {
@@ -478,6 +483,9 @@ func TestMakeWrapper(t *testing.T) {
478483
t.Fail()
479484
}
480485

486+
if !js.Global.Call("eval", `(function(m) { return m.IncF() === undefined })`).Invoke(js.MakeWrapper(m)).Bool() {
487+
t.Fail()
488+
}
481489
}
482490

483491
func TestMakeFullWrapperType(t *testing.T) {

0 commit comments

Comments
 (0)