fix: assign untyped value to typed var may require type conversion

This commit is contained in:
Marc Vertes
2019-10-20 02:30:03 +02:00
committed by Traefiker Bot
parent e193d95dc2
commit ac504a2e8a
2 changed files with 12 additions and 0 deletions

10
_test/assign10.go Normal file
View File

@@ -0,0 +1,10 @@
package main
func main() {
var a uint
a = 1 + 2
println(a)
}
// Output:
// 3

View File

@@ -232,6 +232,8 @@ func assign(n *node) {
svalue[i] = func(*frame) reflect.Value { return reflect.New(t).Elem() }
case isRecursiveStruct(dest.typ, dest.typ.rtype):
svalue[i] = genValueInterfacePtr(src)
case src.typ.untyped && !dest.typ.untyped:
svalue[i] = genValueAs(src, dest.typ.TypeOf())
default:
svalue[i] = genValue(src)
}