-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lkt: emit an error if PropertyError is called without raise
Ensure that PropertyError is called through the raise keyword. TN: U928-029
- Loading branch information
Showing
3 changed files
with
122 additions
and
37 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
15 changes: 11 additions & 4 deletions
15
testsuite/tests/contrib/lkt_semantic/property_error/test.lkt
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 |
---|---|---|
@@ -1,16 +1,23 @@ | ||
fun prop1(): Bool = raise PropertyError("error") | ||
fun prop2(): Bool = (raise PropertyError("error")) | ||
fun prop3(): Bool = raise (PropertyError("error")) | ||
fun prop4(): Bool = raise (((PropertyError("error")))) | ||
|
||
# TODO: prop5 and prop6 should be rejected (we don't want any PropertyError | ||
# value living outside of the exception system). | ||
# @invalid fun prop5(): PropertyError = raise PropertyError() | ||
# @invalid fun prop6(): Bool = raise prop5() | ||
|
||
# Invalid because of missing raise keyword | ||
@invalid val prop3: Bool = PropertyError("error") | ||
@invalid val prop4: Bool = (PropertyError("error")) | ||
@invalid val prop7: Bool = PropertyError("error") | ||
@invalid val prop8: Bool = (PropertyError("error")) | ||
|
||
fun prop5(): Bool = { | ||
fun prop9(): Bool = { | ||
val n: Int = 1; | ||
|
||
raise PropertyError("Explicit error") | ||
} | ||
|
||
# Invalid because only PropertyError can be raised | ||
val i: Int = 1 | ||
@invalid fun prop6(): Bool = raise i | ||
@invalid fun prop10(): Bool = raise i |
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