diff --git a/cty/msgpack/marshal.go b/cty/msgpack/marshal.go index 27da762..274d559 100644 --- a/cty/msgpack/marshal.go +++ b/cty/msgpack/marshal.go @@ -32,7 +32,10 @@ func Marshal(val cty.Value, ty cty.Type) ([]byte, error) { var buf bytes.Buffer enc := msgpack.NewEncoder(&buf) enc.UseCompactInts(true) - enc.UseCompactFloats(true) + + // UseCompactFloats can fail on some platforms due to undefined behavior of + // float conversions + enc.UseCompactFloats(false) err := marshal(val, ty, path, enc) if err != nil { diff --git a/cty/msgpack/roundtrip_test.go b/cty/msgpack/roundtrip_test.go index 497919b..5b73ea9 100644 --- a/cty/msgpack/roundtrip_test.go +++ b/cty/msgpack/roundtrip_test.go @@ -84,6 +84,18 @@ func TestRoundTrip(t *testing.T) { bigNumberVal, cty.Number, }, + { + cty.MustParseNumberVal("9223372036854775807"), + cty.Number, + }, + { + cty.MustParseNumberVal("9223372036854775808"), + cty.Number, + }, + { + cty.MustParseNumberVal("9223372036854775809"), + cty.Number, + }, { awkwardFractionVal, cty.Number,