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(gonative): add constant information when we define a go native value #2848

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

omarsy
Copy link
Member

@omarsy omarsy commented Sep 25, 2024

First part of the fix: #2836

The second part is addressed here: #2731

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Sep 25, 2024
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 97.67442% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.97%. Comparing base (69400d4) to head (0671c88).
Report is 42 commits behind head on master.

Files with missing lines Patch % Lines
gnovm/pkg/gnolang/gonative.go 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2848      +/-   ##
==========================================
+ Coverage   60.90%   60.97%   +0.07%     
==========================================
  Files         564      564              
  Lines       75273    75279       +6     
==========================================
+ Hits        45844    45902      +58     
+ Misses      26057    26008      -49     
+ Partials     3372     3369       -3     
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
gno.land 67.92% <ø> (+0.75%) ⬆️
gnovm 65.78% <97.67%> (+<0.01%) ⬆️
misc/genstd 80.54% <ø> (ø)
misc/logos 20.23% <ø> (+0.35%) ⬆️
tm2 62.11% <ø> (+0.04%) ⬆️

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 marked this pull request as ready for review September 25, 2024 14:34
@omarsy omarsy changed the title fix(gonative): add constant information when we define a go native v… fix(gonative): add constant information when we define a go native value Sep 25, 2024
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

I think all values declared using gonative should be not modifiable.

Can we just have that if you have an assignment on a value which is statically typed as a native value, you cannot change it?

@omarsy
Copy link
Member Author

omarsy commented Oct 2, 2024

I think all values declared using gonative should be not modifiable.

Can we just have that if you have an assignment on a value which is statically typed as a native value, you cannot change it?

We have an example of editing a native value here: https://github.com/gnolang/gno/blob/master/gnovm/tests/files/assign0b_native.gno. I'm unsure if this is something we want to prohibit.

@thehowl
Copy link
Member

thehowl commented Oct 2, 2024

The fact that values are modifiable makes functions modifiable, too:

package main

import (
	"fmt"
)

func main() {
	fmt.Sprintf = func(v string, p ...interface{}) string { return "123" }
	println(fmt.Sprintf("a", "b"))
}

// Output:
// 123

Seeing as we eventually want to remove gonative (#1361), I think it's sensible to remove the ability to modify these entirely.

@omarsy
Copy link
Member Author

omarsy commented Oct 2, 2024

Yes maybe we should forbid the edit only for functions and constants. WDYT ?

@thehowl
Copy link
Member

thehowl commented Oct 2, 2024

Whatever is simplest.

@omarsy
Copy link
Member Author

omarsy commented Oct 2, 2024

Added here: 0671c88

Nice catch for the issue ^^

@Kouteki Kouteki added review/triage-pending PRs opened by external contributors that are waiting for the 1st review and removed review/triage-pending PRs opened by external contributors that are waiting for the 1st review labels Oct 3, 2024
@omarsy omarsy requested a review from thehowl October 18, 2024 16:13
@thehowl thehowl merged commit 88a0c4e into gnolang:master Oct 21, 2024
119 checks passed
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: Done
Development

Successfully merging this pull request may close these issues.

Assignment to Constant Pkg Value in Gno
3 participants