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(gnovm): improve error message for nil assignment in variable decl… #3068

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

omarsy
Copy link
Member

@omarsy omarsy commented Nov 4, 2024

…aration

Contributors' checklist...
  • 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
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.34%. Comparing base (e3995b9) to head (a67d677).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3068   +/-   ##
=======================================
  Coverage   63.33%   63.34%           
=======================================
  Files         548      548           
  Lines       78599    78599           
=======================================
+ Hits        49784    49791    +7     
+ Misses      25461    25454    -7     
  Partials     3354     3354           
Flag Coverage Δ
contribs/gnodev 61.11% <ø> (ø)
contribs/gnofaucet 14.82% <ø> (ø)
gnovm 67.89% <100.00%> (+0.01%) ⬆️
misc/genstd 79.72% <ø> (ø)
tm2 62.42% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@omarsy omarsy force-pushed the fix/improve-nil-not-assignable branch from f8443e5 to a67d677 Compare November 4, 2024 22:57
}

// Error:
// main/files/assign29.gno:5:2: cannot use nil as int value in variable declaration
Copy link
Member Author

Choose a reason for hiding this comment

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

should be cannot use nil as int value in assignment

@@ -289,7 +289,7 @@ func checkAssignableTo(xt, dt Type, autoNative bool) error {
// case0
if xt == nil { // see test/files/types/eql_0f18
if !maybeNil(dt) {
panic(fmt.Sprintf("invalid operation, nil can not be compared to %v", dt))
panic(fmt.Sprintf("cannot use nil as %v value in variable declaration", dt))
Copy link
Contributor

Choose a reason for hiding this comment

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

thank you for tackling this.

@ltzmaxwell
Copy link
Contributor

ltzmaxwell commented Nov 5, 2024

can you add some more tests like a + nil, etc. ? I guess there would be no more side effect but it's still worth to be clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: No status
Status: Triage
Development

Successfully merging this pull request may close these issues.

2 participants