-
Notifications
You must be signed in to change notification settings - Fork 378
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: untyped values use calling builtin function's type #1423
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1423 +/- ##
==========================================
- Coverage 56.31% 55.79% -0.53%
==========================================
Files 422 431 +9
Lines 65699 68649 +2950
==========================================
+ Hits 37000 38303 +1303
- Misses 25817 27381 +1564
- Partials 2882 2965 +83
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
The fix works well. There is a simpler alternative though. Please see the inline comments. WDYT?
@deelawn awesome, LGTM |
<!-- please provide a detailed description of the changes made in this pull request. --> Addresses gnolang#1085 The call to `convConst` should include the type in this case. This happens while processing a `CallExpr` and in this case the expression is a function call to the built function `uint64`. We have the expected type, so use when converting the constant to a typed value. If this type is still nil, then it will behave as it does currently. However, the concrete type should only be supplied to `convertConst` if the call expression's type and the constant expression's type both have the same underlying _unsigned type_ -- the base type of any value of these types were they to be evaluated as literals before being assigned a type. <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>
Addresses #1085
The call to
convConst
should include the type in this case. This happens while processing aCallExpr
and in this case the expression is a function call to the built functionuint64
. We have the expected type, so use when converting the constant to a typed value. If this type is still nil, then it will behave as it does currently.However, the concrete type should only be supplied to
convertConst
if the call expression's type and the constant expression's type both have the same underlying unsigned type -- the base type of any value of these types were they to be evaluated as literals before being assigned a type.Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description