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

go2Gno loses type info #1966

Closed
ltzmaxwell opened this issue Apr 22, 2024 · 3 comments · Fixed by #2016
Closed

go2Gno loses type info #1966

ltzmaxwell opened this issue Apr 22, 2024 · 3 comments · Fixed by #2016
Labels
📦 🤖 gnovm Issues or PRs gnovm related

Comments

@ltzmaxwell
Copy link
Contributor

see this:

package main

import (
	"fmt"
	"time"
)

func main() {
	var a int64 = 2
	//fmt.Println(a * time.Second)
	fmt.Println(time.Second * a)
}

this would not compile in Go, but works in gno. the reason for it is while converting from go to gno, time.Duration is treated as a int64 rather than the time.Duration, the declared type is lost.

@zivkovicmilos zivkovicmilos added 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels Apr 26, 2024
@Kouteki Kouteki removed the 🐞 bug Something isn't working label Apr 26, 2024
@omarsy
Copy link
Contributor

omarsy commented Apr 28, 2024

Maybe the issue has been resolved. I will try to reproduce it. I encountered an issue with the compilation.

Code:

package time

import (
	"fmt"
	"std"
	"testing"
	"time"
)

func TestTime(t *testing.T) {
	var a int64 = 2
	fmt.Println(time.Second * a)
}

Issue on lint: time_test.gno:12: incompatible types in binary expression: time<VPBlock(2,3)>.Second MUL a<VPBlock(1,1)> (code=2).

@ltzmaxwell
Copy link
Contributor Author

ltzmaxwell commented Apr 28, 2024

It happens when test with native, you can check _test.gnolang.native in gnovm/Makefile.
Thank you for your work!

omarsy added a commit to TERITORI/gno that referenced this issue May 1, 2024
omarsy added a commit to TERITORI/gno that referenced this issue May 1, 2024
omarsy added a commit to TERITORI/gno that referenced this issue May 1, 2024
@omarsy
Copy link
Contributor

omarsy commented May 1, 2024

It happens when test with native, you can check _test.gnolang.native in gnovm/Makefile. Thank you for your work!

Thank you I can reproduce it now :)

thehowl pushed a commit that referenced this issue May 23, 2024
#2016)

fixes #1966 
<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [ ] 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
- [ ] 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>
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
Development

Successfully merging a pull request may close this issue.

4 participants