Closed waymobetta closed 5 months ago
We cannot support floats due to potential non-deterministic results using amino to encode floats; they need to be passed as strings if the realm function wants to use them. Leaving this open because a better solution might be to add some additional checks either when calling addpkg
or maketx
to return a better error message that indicates float values are not supported.
:thinking:
I mean, I'm pretty sure argument parsing in maketx calls just combines the function into an expression to call the given function. So, ultimately, it's the gnovm parsing a literal, and we already have the code to do that...
Unexpected primitive type:
float32
andfloat64
Description
NOTE: The below also holds true for
float64
.I just tried to use
float32
in a realm and am getting the error:unexpected primitive type float32
.Your environment
Mac: Sonoma 14.1.2 Gno: v0.0.1-dev.2023.12.01 Master branch
Steps to reproduce
Something like the following could be used within a realm to recreate this error.
NOTE: When doing arithmetic with variables defined within the function scope, everything is fine (version 0); when performing arithmetic with variables that are passed in via transaction (gnokey), the error occurs (version 1).
It is possible that I am not passing in values correctly to
gnokey
.Version 0:
Version 1:
Gnokey Tx:
Expected behaviour
Variables should be added together and returned as
float32
Actual behaviour
Error:
Unexpected primitive type: float32
Logs
Proposed solution
Possibly
float32
is not supported? https://github.com/gnolang/gno/blob/master/gno.land/pkg/sdk/vm/convert.go#L156