Skip to content

spec: comma-ok expressions should return an untyped bool rather than a bool #8189

Closed
@griesemer

Description

@griesemer
All comma-ok expressions return an ok value of type bool at the moment:

- map index: http://tip.golang.org/ref/spec#Index_expressions
- type assertion: http://tip.golang.org/ref/spec#Type_assertions
- channel receive: http://tip.golang.org/ref/spec#Receive_operator

There is no reason for them to not return an untyped bool instead:

- an untyped bool can be assigned to any bool variable
- an untyped bool will default to a bool type in a declaration (var _, ok = ... ; or _,
ok := ...)
- an untyped bool will default to a bool type in an assignment to an interface

This would be a completely backward-compatible language change.

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