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

Skip to content

Conversion between pointer-to-array types doesn't preserve nil #1241

Open
@nevkontakte

Description

@nevkontakte

Example:

package main

import (
	"fmt"
)

type arrPtr *[3]byte

func main() {
	var s1 *[3]byte = nil
	var s2 arrPtr = arrPtr(s1)
	var s3 arrPtr = nil
	fmt.Println(s1, s2, s3)
}

Expected output: <nil> <nil> <nil>.

Actual output: <nil> &[] <nil>.

Proximate cause: here, instead of treating the conversion is a no-op, it should check if the original value was a nil pointer of the original type, and return the nil object of the desired type. Counter-intuitively, in GopherJS each type that can be nil represents the nil value with its own unique object. This issue is one of the motivating examples for #1238.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions