Skip to content

Commit 8f13336

Browse files
author
Paddy Carver
committed
Numbers are special.
When unmarshaling numbers, we want to handle them special so provider developers don't have to guess whether they're getting an int, int8, int16, int32, int64, uint, uint8, big.Float, or whatever. We should have a single, consistent number type with easy conversion to the standard number types. Or just use a `big` variant? Not sure yet, needs more investigation and thinking. For now: TODO so we don't forget.
1 parent f007577 commit 8f13336

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tfprotov5/tftypes/raw_value.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,17 @@ func (r RawValue) Unmarshal(dst interface{}) error {
258258

259259
func rawValueFromComplexType(typ Type, val interface{}) (RawValue, error) {
260260
if _, ok := typ.(primitive); ok {
261+
if typ.Is(Number) {
262+
// TODO: put numbers in a consistent format
263+
// numbers could be coming to us as like a billion
264+
// different types, and we want developers to have
265+
// stable types to build against. We should cast or
266+
// wrap as necessary here to handle that.
267+
return RawValue{
268+
Type: Number,
269+
Value: val,
270+
}
271+
}
261272
return RawValue{
262273
Type: typ,
263274
Value: val,

0 commit comments

Comments
 (0)