From 659913eebe2d820f50729dc6c7cf9ac47e868247 Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Wed, 8 Jul 2020 22:55:03 +0200 Subject: [PATCH] fix: convert type properly to the correct type --- _test/composite11.go | 15 +++++++++++++++ interp/run.go | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 _test/composite11.go diff --git a/_test/composite11.go b/_test/composite11.go new file mode 100644 index 00000000..85f71018 --- /dev/null +++ b/_test/composite11.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "image/color" +) + +func main() { + c := color.NRGBA64{1, 1, 1, 1} + + fmt.Println(c) +} + +// Output: +// {1 1 1 1} diff --git a/interp/run.go b/interp/run.go index b70afa92..a85206d8 100644 --- a/interp/run.go +++ b/interp/run.go @@ -2011,10 +2011,11 @@ func compositeBinStruct(n *node) { } } else { fieldIndex[i] = []int{i} - convertLiteralValue(c.child[1], typ.Field(i).Type) if c.typ.cat == funcT { + convertLiteralValue(c.child[1], typ.Field(i).Type) values[i] = genFunctionWrapper(c.child[1]) } else { + convertLiteralValue(c, typ.Field(i).Type) values[i] = genValue(c) } }