-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds validation for `break`, `continue` and `fallthrough` to disallow invalid code. Moves existing validation from the runtime to the preprocessor. Closes #2973
- Loading branch information
1 parent
6a13619
commit 0246761
Showing
13 changed files
with
151 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
continue | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for21.gno:7:17: continue statement out of place |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
fallthrough | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for22.gno:7:17: fallthrough statement out of place |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
break | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for23.gno:7:17: break statement out of place |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
if true { | ||
break | ||
} | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for24.gno:8:21: break statement out of place |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters