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

Constant Declaration with Slice Type Compiles Without Error #2628

Open
omarsy opened this issue Jul 24, 2024 · 1 comment · May be fixed by #2828
Open

Constant Declaration with Slice Type Compiles Without Error #2628

omarsy opened this issue Jul 24, 2024 · 1 comment · May be fixed by #2828
Assignees
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@omarsy
Copy link
Member

omarsy commented Jul 24, 2024

Description:

Issue Summary:

Declaring a constant with a slice type should result in a compilation error, as slices are not valid constant types. However, the following code compiles and runs without error:

package main

func main() {
	const b []string = []string{}
	println("Hello", b)
}

Expected Behavior:

The code should not compile, and an error should be thrown indicating that slices cannot be used as constant types. This behavior is consistent with Go (Golang), where a similar code snippet results in an error stating invalid constant type []string.

Actual Behavior:

The code compiles and runs without any errors, printing "Hello" followed by the empty slice. This suggests that Gnolang does not enforce the expected type restrictions on constants.

@thehowl
Copy link
Member

thehowl commented Jul 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Teritori (confirmed)
Status: In Progress
4 participants