-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Add a test for invalid use of opaque resources
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is free and unencumbered software released into the public domain. | ||
# See ../LICENSE.unlicense | ||
|
||
# PLZTEST type compile_failure | ||
|
||
[opaque_resource_2] | ||
type = program | ||
modules = [OpaqueResource2, OpaqueResource] | ||
|
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,2 @@ | ||
opaque_resource_2.p:22: One or more resources needed for this call is | ||
unavailable in this function |
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,28 @@ | ||
/* | ||
* vim: ft=plasma | ||
* This is free and unencumbered software released into the public domain. | ||
* See ../LICENSE.unlicense | ||
*/ | ||
|
||
module OpaqueResource2 | ||
|
||
import OpaqueResource as OR | ||
|
||
entrypoint | ||
func test() uses IO -> Int { | ||
var s = test2!("Bob") | ||
print!(s ++ "\n") | ||
|
||
return 0 | ||
} | ||
|
||
func test2(s : String) uses OR.Res1 -> String { | ||
// Calling test3 directly is illegal. although Res2 comes from Res1 this | ||
// module doesn't know that because Res2 is opaque. | ||
return test3!(s) | ||
} | ||
|
||
func test3(s : String) uses OR.Res2 -> String { | ||
return "Hi " ++ s ++ "." | ||
} | ||
|