aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2018-12-20 11:10:06 -0800
committerMatthew Dempsky <mdempsky@google.com>2018-12-20 19:35:04 +0000
commit706b54bb85df2eb9a21da9e049fd1dff77342d25 (patch)
treebfdc14abe0e2895ebcaa3c0c1572de3eb3135581 /src
parent8ff04a9966083f982ecaa57f7bcc786aa7316ec8 (diff)
downloadgo-706b54bb85df2eb9a21da9e049fd1dff77342d25.tar.xz
cmd/compile: fix ICE due to bad rune width
It was possible that var X interface{} = 'x' could cause a compilation failure due to having not calculated rune's width yet. typecheck.go normally calculates the width of things, but it doesn't for implicit conversions to default type. We already compute the width of all of the standard numeric types in universe.go, but we failed to calculate it for the rune alias type. So we could later crash if the code never otherwise explicitly mentioned 'rune'. While here, explicitly compute widths for 'byte' and 'error' for consistency. Fixes #29350. Change-Id: Ifedd4899527c983ee5258dcf75aaf635b6f812f8 Reviewed-on: https://go-review.googlesource.com/c/155380 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/universe.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/universe.go b/src/cmd/compile/internal/gc/universe.go
index 745ce66bba..104c6bab23 100644
--- a/src/cmd/compile/internal/gc/universe.go
+++ b/src/cmd/compile/internal/gc/universe.go
@@ -386,6 +386,7 @@ func lexinit1() {
types.Errortype.Sym = s
types.Errortype.Orig = makeErrorInterface()
s.Def = asTypesNode(typenod(types.Errortype))
+ dowidth(types.Errortype)
// We create separate byte and rune types for better error messages
// rather than just creating type alias *types.Sym's for the uint8 and
@@ -401,6 +402,7 @@ func lexinit1() {
types.Bytetype.Sym = s
s.Def = asTypesNode(typenod(types.Bytetype))
asNode(s.Def).Name = new(Name)
+ dowidth(types.Bytetype)
// rune alias
s = builtinpkg.Lookup("rune")
@@ -408,6 +410,7 @@ func lexinit1() {
types.Runetype.Sym = s
s.Def = asTypesNode(typenod(types.Runetype))
asNode(s.Def).Name = new(Name)
+ dowidth(types.Runetype)
// backend-dependent builtin types (e.g. int).
for _, s := range typedefs {