Skip to content
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

fix: fix conversion from int to float64 #753

Merged
merged 2 commits into from
Jun 9, 2024
Merged
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
12 changes: 10 additions & 2 deletions interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,16 @@ func jsonToValue(i *interpreter, v interface{}) (value, error) {

case bool:
return makeValueBoolean(v), nil
case int, int8, int16, int32, int64:
return makeDoubleCheck(i, v.(float64))
case int:
return makeDoubleCheck(i, float64(v))
case int8:
return makeDoubleCheck(i, float64(v))
case int16:
return makeDoubleCheck(i, float64(v))
case int32:
return makeDoubleCheck(i, float64(v))
case int64:
return makeDoubleCheck(i, float64(v))
Comment on lines +952 to +961
Copy link
Contributor Author

@suzuki-shunsuke suzuki-shunsuke Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't merge these case for type assertion.
If these case are merged, the type of v becomes interface{} so we can't convert the value to float64.

cannot convert v (variable of type interface{}) to type float64: need type assertion

case float64:
return makeDoubleCheck(i, v)

Expand Down
Loading