-
Notifications
You must be signed in to change notification settings - Fork 375
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
Unexpected primitive type: float32
and float64
#1427
Comments
float32
float32
and float64
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 Line 94 in 968f89e
|
🤔 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... |
<!-- please provide a detailed description of the changes made in this pull request. --> Addresses #1427 This allows passing in float types to contract functions <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Co-authored-by: Hariom Verma <hariom18599@gmail.com>
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
The text was updated successfully, but these errors were encountered: