-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: repro and fix for issue-4297 (#4306)
repro and (ugly) fix for issue #4297: Moc let's you compile a sequence of declarations as an implicit actor, which is used by some of our drun tests and was stumbled on by a user. Unfortunately, we failed to set up the initial environment corrrectly, so those declarations could do async/await at top-level (i.e. in the body of the actor), which should be illegal and rejected (while not being rejected for interpreted code, whose top-level is allowed to async/await). The hacky fix is to inspect the progs being compiled using `CompUnit.comp_unit_of_prog` and set up the initial capability appropriately. Even better would be to pass the capability down somehow, but this turns out to be trickier than expected. To avoid clobbering the existing tests too much, we also make typing functions that check the current static capability return local_errors (not errors) on failure, to continue with typechecking and report any other static errors. Added bonus: setting up the capabilities properly prevents us from doing top-level async/await in the prelude, which would otherwise wreak all sorts of havoc in compile.ml due to unexpected renaming of well-known prelude functions due to cps conversion.
- Loading branch information
Showing
27 changed files
with
129 additions
and
35 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
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
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
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
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
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 +1,4 @@ | ||
await-in-actor.mo:3.13-3.30: type error [M0038], misplaced await | ||
await-in-actor.mo:3.21-3.28: type error [M0037], misplaced async expression; try enclosing in an async function | ||
await-in-actor.mo:3.13-3.30: type error [M0038], misplaced await | ||
await-in-actor.mo:3.21-3.28: type error [M0037], misplaced async expression; try enclosing in an async 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
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 @@ | ||
await async {}; |
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,2 +1,11 @@ | ||
aritybug.mo:13.41-15.2: type error [M0077], a shared function is only allowed as a public field of an actor | ||
(This is a limitation of the current version and flag -ref-system-api.) | ||
aritybug.mo:17.25-22.2: type error [M0037], misplaced async expression; try enclosing in an async function | ||
aritybug.mo:17.25-22.2: type error [M0092], async at scope | ||
$bogus | ||
cannot produce expected scope | ||
$top-level | ||
scope $top-level is the global scope | ||
aritybug.mo:18.14-18.27: type error [M0038], misplaced await | ||
aritybug.mo:18.20-18.27: type error [M0047], send capability required, but not available | ||
(need an enclosing async expression or function body) |
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,2 +1,11 @@ | ||
aritybug.mo:13.41-15.2: type error [M0077], a shared function is only allowed as a public field of an actor | ||
(This is a limitation of the current version.) | ||
aritybug.mo:17.25-22.2: type error [M0037], misplaced async expression; try enclosing in an async function | ||
aritybug.mo:17.25-22.2: type error [M0092], async at scope | ||
$bogus | ||
cannot produce expected scope | ||
$top-level | ||
scope $top-level is the global scope | ||
aritybug.mo:18.14-18.27: type error [M0038], misplaced await | ||
aritybug.mo:18.20-18.27: type error [M0047], send capability required, but not available | ||
(need an enclosing async expression or function body) |
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 +1,3 @@ | ||
inter-query.mo:3.48-3.59: type error [M0038], misplaced await | ||
inter-query.mo:3.54-3.59: type error [M0188], send capability required, but not available | ||
(cannot call a `shared` function from a `query` 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
issue-1938-b.mo:2.1-2.9: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version and flag -ref-system-api.) | ||
issue-1938-b.mo:2.1-2.9: type error [M0038], misplaced await | ||
issue-1938-b.mo:2.1-2.9: type error [M0037], misplaced async expression; try enclosing in an async 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
issue-1938-b.mo:2.1-2.9: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version.) | ||
issue-1938-b.mo:2.1-2.9: type error [M0038], misplaced await | ||
issue-1938-b.mo:2.1-2.9: type error [M0037], misplaced async expression; try enclosing in an async 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
issue-1938-c.mo:2.1-2.11: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version and flag -ref-system-api.) | ||
issue-1938-c.mo:2.1-2.11: type error [M0038], misplaced await | ||
issue-1938-c.mo:2.1-2.11: type error [M0037], misplaced async expression; try enclosing in an async 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
issue-1938-c.mo:2.1-2.11: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version.) | ||
issue-1938-c.mo:2.1-2.11: type error [M0038], misplaced await | ||
issue-1938-c.mo:2.1-2.11: type error [M0037], misplaced async expression; try enclosing in an async 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
issue-1938.mo:2.1-2.11: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version and flag -ref-system-api.) | ||
issue-1938.mo:2.1-2.11: type error [M0038], misplaced await | ||
issue-1938.mo:2.1-2.11: type error [M0037], misplaced async expression; try enclosing in an async 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
issue-1938.mo:2.1-2.11: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version.) | ||
issue-1938.mo:2.1-2.11: type error [M0038], misplaced await | ||
issue-1938.mo:2.1-2.11: type error [M0037], misplaced async expression; try enclosing in an async 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,2 @@ | ||
issue-4297.mo:1.1-1.15: type error [M0038], misplaced await | ||
issue-4297.mo:1.7-1.15: type error [M0037], misplaced async expression; try enclosing in an async 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 @@ | ||
Return code 1 |
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 @@ | ||
issue-4297.mo:1.1-1.15: type error [M0038], misplaced await | ||
issue-4297.mo:1.7-1.15: type error [M0037], misplaced async expression; try enclosing in an async 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 @@ | ||
Return code 1 |
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 +1,8 @@ | ||
scope-example-func-implicit.mo:7.13-7.22: type error [M0037], misplaced async expression; try enclosing in an async function | ||
scope-example-func-implicit.mo:7.13-7.22: type error [M0092], async at scope | ||
$bogus | ||
cannot produce expected scope | ||
$f | ||
scope $f is scope-example-func-implicit.mo:3.43-17.4 | ||
scope-example-func-implicit.mo:3.43: info, start of scope $f mentioned in error at scope-example-func-implicit.mo:7.13-7.22 | ||
scope-example-func-implicit.mo:17.3: info, end of scope $f mentioned in error at scope-example-func-implicit.mo:7.13-7.22 |
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 +1,8 @@ | ||
scope-example-func.mo:10.13-10.38: type error [M0037], misplaced async expression; try enclosing in an async function | ||
scope-example-func.mo:10.13-10.38: type error [M0092], async at scope | ||
$bogus | ||
cannot produce expected scope | ||
$anon-async-5.60 | ||
scope $anon-async-5.60 is scope-example-func.mo:5.60-21.4 | ||
scope-example-func.mo:5.60: info, start of scope $anon-async-5.60 mentioned in error at scope-example-func.mo:10.13-10.38 | ||
scope-example-func.mo:21.3: info, end of scope $anon-async-5.60 mentioned in error at scope-example-func.mo:10.13-10.38 |
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,2 +1,4 @@ | ||
unsupported-more.mo:2.1-5.2: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version and flag -ref-system-api.) | ||
unsupported-more.mo:2.1-5.2: type error [M0038], misplaced await | ||
unsupported-more.mo:2.1-5.2: type error [M0037], misplaced async expression; try enclosing in an async function | ||
unsupported-more.mo:8.1-8.25: type error [M0038], misplaced await | ||
unsupported-more.mo:8.1-8.25: type error [M0037], misplaced async expression; try enclosing in an async 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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
unsupported-more.mo:2.1-5.2: type error [M0141], an actor or actor class must be the only non-imported declaration in a program | ||
(This is a limitation of the current version.) | ||
unsupported-more.mo:2.1-5.2: type error [M0038], misplaced await | ||
unsupported-more.mo:2.1-5.2: type error [M0037], misplaced async expression; try enclosing in an async function | ||
unsupported-more.mo:8.1-8.25: type error [M0038], misplaced await | ||
unsupported-more.mo:8.1-8.25: type error [M0037], misplaced async expression; try enclosing in an async 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
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