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

GnoVM: Constant expressions do not work with some built-in functions #2829

Closed
omarsy opened this issue Sep 21, 2024 · 4 comments
Closed

GnoVM: Constant expressions do not work with some built-in functions #2829

omarsy opened this issue Sep 21, 2024 · 4 comments
Labels
🐞 bug Something isn't working

Comments

@omarsy
Copy link
Contributor

omarsy commented Sep 21, 2024

Description

In Go, the following code snippet compiles and runs correctly, using the built-in min/ max function within a constant expression:

package main

func main() {
	const t = min(0, 1)
	println(t)
}

However, when using the same code in Gno, it returns an error:

name min not defined in fileset with files 

Expected Behavior

The code should compile successfully in Gno, similar to how it works in Go, allowing the use of built-in functions in constant expressions.

@moul moul added the 🐞 bug Something isn't working label Sep 21, 2024
@leohhhn leohhhn changed the title Constant Expressions Not Work With Some Built-in Functions GnoVM: Constant expressions do not work with some built-in functions Sep 23, 2024
@leohhhn
Copy link
Contributor

leohhhn commented Sep 23, 2024

As far as I can see, min & max were introduced in Go 1.21; Gno is based on 1.17, so this is not supported yet. Will keep the issue open for visibility.

@thehowl
Copy link
Member

thehowl commented Sep 23, 2024

if you find this is the case for other constant expressions (like len([2]int{1, 2}), which should yield the constant-expr 2), then please open another issue.

as leon said, min/max are not supported yet, we'll need generics #1748 before that

@thehowl thehowl closed this as completed Sep 23, 2024
@omarsy
Copy link
Contributor Author

omarsy commented Sep 23, 2024

maybe we should return the right error for that "name min/max not declared"

@thehowl
Copy link
Member

thehowl commented Sep 23, 2024

yeah, you're welcome to adapt the error message, i agree it's unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Development

No branches or pull requests

4 participants