Skip to content

Nil slice becomes non-nil after slicing. #851

@dmitshur

Description

@dmitshur

According to the Go spec on slice expressions:

If the sliced operand of a valid slice expression is a nil slice, the result is a nil slice.

var s []int
s = s[0:0]
fmt.Println(s == nil) // should be true

GopherJS doesn't currently implement that. Slicing a nil slice keeps it empty but makes it non-nil:

I discovered this bug as part of the work to support Go 1.11, because this bug started to cause go/doc tests to fail (see #836 (comment)).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions