golang/go
cmd/compile: clearer error message for unkeyed composite literal with unexported field
已关闭
#28,053 创建于 2018年10月6日
BadErrorMessageFixPendingcompiler/runtimehelp wanted
仓库指标
- 星标
- (133,883 个星标)
- PR 合并指标
- (30 天内没有已合并 PR)
描述
I have a struct:
package df
type SortKey struct {
Key interface{}
SortDesc bool
seriesIndex int
}
From an outside package:
TRY 1
z := df.SortKey{"n", false}
Compiler error: too few values in df.SortKey literal
TRY 2
z := df.SortKey{"n", false, 0}
Compiler error: implicit assignment of unexported field 'seriesIndex' in df.SortKey literal
You can't win. Perhaps it should just be disallowed for Go 2 - It messes up backwards compatibility anyway amongst minor versions of packages (eg. net/http.Request and Context situation).