Skip to content

go/types: Instantiate has user-unfriendly panics #79709

Description

@dominikh

go/types.Instantiate uses an assert helper in multiple places, leading to unhelpful "assertion failed" panics for external users. It would be nice if those would instead tell the user what they did wrong.

The type assertion to genericType also isn't the nicest it could be, as user error leads to a panic mentioning an unexported type--but at least the name is pretty indicative of what's wrong.

(It's unfortunate that Instantiate is documented not to return errors when validate is false, as most of the panics could've been errors instead.)

Metadata

Metadata

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions