-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds logic for switch case to be the last statement in a function and be detected for return values.
- Loading branch information
Showing
4 changed files
with
48 additions
and
7 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
12 changes: 12 additions & 0 deletions
12
data/expression2/tests/compiler/compiler/restrictions/fn_return_switch.txt
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,12 @@ | ||
## SHOULD_FAIL:COMPILE | ||
|
||
function string failure() { | ||
switch (5) { | ||
case 2, | ||
break | ||
default, | ||
break | ||
|
||
# 'break' does not return a value or cause a runtime error, just early returns switch. | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
data/expression2/tests/compiler/compiler/restrictions/fn_return_switch2.txt
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,9 @@ | ||
## SHOULD_FAIL:COMPILE | ||
|
||
function string failure() { | ||
switch (5) { | ||
case 2, | ||
return "boowomp" | ||
# no default case, compiler can't guarantee that this always runs, fails to compile. | ||
} | ||
} |
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