Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug in fallthrough of $internalize pointer types. #1301

Closed as not planned
Closed as not planned
@davewalker-wk

Description

@davewalker-wk

The following highlights a problem when $internalize ing a pointer type. It only will internalize if the pointer is a struct; otherwise it will fallthrough into internalizing as a slice.

Suspect code: https://github.com/gopherjs/gopherjs/blob/master/compiler/prelude/jsmapping.js#L329-L334

//go:build js

package test

import (
	"fmt"
	"github.com/gopherjs/gopherjs/js"
	"testing"
)

type Bar struct {
	*js.Object
	V *string `js:"V"`
}

func makeJsObject() *js.Object {
	if js.Global != nil {
		return js.Global.Get("Object").New()
	}

	return nil
}

func TestExposeBug(t *testing.T) {
	b := Bar{Object: makeJsObject()}
	b.V = nil
	elem := b.V
	fmt.Println(elem)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions