diff --git a/tests/modules/opaque_resource_2.build b/tests/modules/opaque_resource_2.build new file mode 100644 index 00000000..f8082cc6 --- /dev/null +++ b/tests/modules/opaque_resource_2.build @@ -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] + diff --git a/tests/modules/opaque_resource_2.exp b/tests/modules/opaque_resource_2.exp new file mode 100644 index 00000000..82dc15c0 --- /dev/null +++ b/tests/modules/opaque_resource_2.exp @@ -0,0 +1,2 @@ +opaque_resource_2.p:22: One or more resources needed for this call is + unavailable in this function diff --git a/tests/modules/opaque_resource_2.p b/tests/modules/opaque_resource_2.p new file mode 100644 index 00000000..be4981f2 --- /dev/null +++ b/tests/modules/opaque_resource_2.p @@ -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 ++ "." +} +