Skip to content

Unmarshalling without type info prefers int64. #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bench/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func fixFloatsToInts(in interface{}) interface{} {
}
return out
case float64:
return int(in2)
return int64(in2)
default:
return in
}
Expand Down
8 changes: 4 additions & 4 deletions bench/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ var fixture_mapAlpha = map[string]interface{}{
},
"C": map[string]interface{}{
"N": "n",
"M": 13,
"M": int64(13),
},
"C2": map[string]interface{}{
"N": "n2",
"M": 14,
"M": int64(14),
},
"X": 1,
"Y": 2,
"X": int64(1),
"Y": int64(2),
"Z": "3",
"W": "4",
}
Expand Down
4 changes: 2 additions & 2 deletions obj/unmarshalBuiltins.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ func (mach *unmarshalMachinePrimitive) Step(_ *Unmarshaller, _ *unmarshalSlab, t
case TBool:
mach.rv.Set(reflect.ValueOf(tok.Bool))
case TInt:
mach.rv.Set(reflect.ValueOf(int(tok.Int))) // Unmarshalling with no particular type info should default to using plain 'int' whenever viable.
mach.rv.Set(reflect.ValueOf(int64(tok.Int))) // Unmarshalling with no particular target type info should consistently map into 'int64' to avoid passing on vagueries of codecs around numeric types.
case TUint:
mach.rv.Set(reflect.ValueOf(int(tok.Uint))) // Unmarshalling with no particular type info should default to using plain 'int' whenever viable.
mach.rv.Set(reflect.ValueOf(int64(tok.Uint))) // Unmarshalling with no particular target type info should consistently map into 'int64' to avoid passing on vagueries of codecs around numeric types.
case TFloat64:
mach.rv.Set(reflect.ValueOf(tok.Float64))
case TNull:
Expand Down