-
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
feat(stdlibs): add package strconv
#1464
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1464 +/- ##
==========================================
+ Coverage 61.11% 63.47% +2.36%
==========================================
Files 565 552 -13
Lines 75396 86833 +11437
==========================================
+ Hits 46077 55117 +9040
- Misses 25950 28135 +2185
- Partials 3369 3581 +212
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
So, tests are currently failing. A bunch of tests I've fixed after realising that the underlying problem is with how we do comparisons when we have a bitshift with an untyped integer on the lhs: #1462 (comment) I suspect there may be more bugs involved. In any case, I attempted to make a separate branch from this which merged in the changes from #1426. Turns out, that the tests are completely passing with that code applied to Gno. So, I'll be continuing work on this once #1426 is merged. For the meantime, I'll update the OP to mark what remaining work is to be done to complete this PR so I can easily pick it up later. |
I did this as an experiment, it passes all the test after making a small adjustment on your code,
|
This PR is now ready for review. I updated the OP with a summary of the changes involved. |
Sounds reasonable, let's do it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a nice one!
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
This PR adds the full
strconv
package, implemented as pure Gno code. It removes the native functionsItoa
(and others), and adds support for new functions such asFormatFloat
.Summary of changes
strconv
from Go stdlib: https://gist.github.com/thehowl/904b42b1ea53fef9b8a0486155c02b73 -- tldr:unicode
strconv
tests succeed.unicode/utf8
fallback
(as we now half-support it) and useAppendString
.store.go
,store_test.go
,nodes.go
,tests/imports.go
.gonative.go
andmachine.go
changes improve some error messages.preprocess.go
changes fix a bug which can be seen in thefor20.gno
test. If afor
loop is labeled, then a barebreak
(ie. without a label to break to) would panic, as it wouldn't find any for loop without a label (infindBranchLabel
). I added a regression test as well as a couple test showing the error message for when we misplace continue/break statements.strconv.Itoa
now uses more gas than its existing native implementation. This is to be expected; we can consider moving it back to a native implementation if we deem it useful for performance, but I think it's good for us to work on having as much code implemented directly in gno before moving it back to Go for performance.