Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions test/fail/issue103.as
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
// A (non-shared) function is not sharable
func invalid1 (f : shared (() -> Nat) -> ()) {
f (func foo() : Nat = 1)
{
func invalid1 (f : shared (() -> Nat) -> ()) {
f (func foo() : Nat = 1)
};
};

// An object with function fields is not sharable
func invalid2 (f : shared {foo : () -> Nat} -> ()) {
f (new { foo() : Nat = 1; })
{
func invalid2 (f : shared {foo : () -> Nat} -> ()) {
f (new { foo() : Nat = 1; })
};
};

// Cannot return a function in an async
func invalid3 () : (async (() -> Nat)) {
async { func foo() : Nat = 1 }
{
func invalid3 () : (async (() -> Nat)) {
async { func foo() : Nat = 1 }
};
};

// Cannot return an object with function fields in an async
func invalid4 () : (async ({foo : () -> Nat})) {
async { new { foo() : Nat = 1; } }
{
func invalid4 () : (async ({foo : () -> Nat})) {
async { new { foo() : Nat = 1; } }
};
};
4 changes: 3 additions & 1 deletion test/fail/ok/issue103.tc.ok
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
issue103.as:2.27-2.38: type error, shared function has non-shared parameter type
issue103.as:3.29-3.40: type error, shared function has non-shared parameter type
() -> Nat
issue103.as:17.29-17.40: type error, async type has non-shared parameter type
() -> Nat