From b036d7e17f1cf5ecf9411e604fbc5bb40dc3dc95 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 24 Aug 2023 17:05:50 -0700 Subject: cmd/compile/internal/noder: avoid ir.Node temps in FixValue Instead of constructing an untyped basic literal IR node, having typecheck convert it and return a new one, only to extract the constant.Value; just have typecheck export the underlying value conversion function, so we can call it directly. Change-Id: Ie98f5362b3926a728d80262b0274a0b4fd023eaf Reviewed-on: https://go-review.googlesource.com/c/go/+/522878 TryBot-Result: Gopher Robot Reviewed-by: Keith Randall Reviewed-by: Cuong Manh Le Auto-Submit: Matthew Dempsky Run-TryBot: Matthew Dempsky --- src/cmd/compile/internal/noder/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/compile/internal/noder') diff --git a/src/cmd/compile/internal/noder/helpers.go b/src/cmd/compile/internal/noder/helpers.go index 5349db3879..8aa93ef5dc 100644 --- a/src/cmd/compile/internal/noder/helpers.go +++ b/src/cmd/compile/internal/noder/helpers.go @@ -58,7 +58,7 @@ func FixValue(typ *types.Type, val constant.Value) constant.Value { val = constant.ToComplex(val) } if !typ.IsUntyped() { - val = typecheck.DefaultLit(ir.NewBasicLit(src.NoXPos, val), typ).Val() + val = typecheck.ConvertVal(val, typ, false) } ir.AssertValidTypeForConst(typ, val) return val -- cgit v1.3