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

can break out of a self-executing closure #2973

Closed
thehowl opened this issue Oct 17, 2024 · 1 comment · Fixed by #3043
Closed

can break out of a self-executing closure #2973

thehowl opened this issue Oct 17, 2024 · 1 comment · Fixed by #3043
Assignees
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@thehowl
Copy link
Member

thehowl commented Oct 17, 2024

In today's episode of "Wouldn't It Be Funny If This Actually Worked?"

package main

func main() {
	for i := 0; i < 10; i++ {
		if i == 1 {
			_ = func() int {
				break
				return 11
			}()
		}
		println(i)
	}
	println("wat???")
}

Of course, this code isn't meant to compile, but Gno's output is a simple and somewhat disarming:

0
wat???
@thehowl thehowl added 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels Oct 17, 2024
@thehowl
Copy link
Member Author

thehowl commented Oct 17, 2024

This can likely work for continue and possibly also fallthrough, so a fix should verify the correct behaviour for all three statements.

@thehowl thehowl added this to the 🚀 Mainnet launch milestone Oct 21, 2024
@Kouteki Kouteki moved this from Triage to Backlog in 🧙‍♂️gno.land core team Oct 22, 2024
@Kouteki Kouteki moved this from Backlog to Todo in 🧙‍♂️gno.land core team Oct 28, 2024
@Kouteki Kouteki moved this from Todo to In Progress in 🧙‍♂️gno.land core team Nov 10, 2024
@Kouteki Kouteki added the in focus Core team is prioritizing this work label Nov 17, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 🧙‍♂️gno.land core team Nov 18, 2024
@Kouteki Kouteki removed the in focus Core team is prioritizing this work label Nov 29, 2024
r3v4s pushed a commit to gnoswap-labs/gno that referenced this issue Dec 10, 2024
Adds validation for `break`, `continue` and `fallthrough` to disallow
invalid code.
Moves existing validation from the runtime to the preprocessor.

Closes gnolang#2973
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: Core
Development

Successfully merging a pull request may close this issue.

3 participants