Skip to content

reflect.Select: behavior when called with an empty slice of cases #22733

@AndreyNevolin

Description

@AndreyNevolin

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.9.1

Does this issue reproduce with the latest release?

Don't know

What operating system and processor architecture are you using (go env)?

GOHOSTARCH="amd64"
GOHOSTOS="linux"

What did you do?

active_index, rcv_value, ok := reflect.Select(make([]reflect.SelectCase, 0))

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
package main

import "reflect"
import "fmt"

func main() {
active_index, rcv_value, ok := reflect.Select(make([]reflect.SelectCase, 0))
fmt.Println(active_index, rcv_value, ok)
}

What did you expect to see?

I don't know. The behavior of "reflect.Select" called with an empty slice is not documented anywhere as I can judge.
I would prefer the call to return an error. But I don't know what is the intended behavior. Maybe the developers consider "hanging forever" behavior the right option.

Please consider changing or documenting the behavior of "reflect.Select" called with an empty slice.

What did you see instead?

The following message:
fatal error: all goroutines are asleep - deadlock!

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