diff --git a/src/mo_frontend/typing.ml b/src/mo_frontend/typing.ml index de5322f6d39..b67cddc0c3b 100644 --- a/src/mo_frontend/typing.ml +++ b/src/mo_frontend/typing.ml @@ -60,7 +60,7 @@ let env_of_scope msgs scope = objs = T.Env.empty; labs = T.Env.empty; rets = None; - async = C.initial_cap(); + async = Async_cap.NullCap; in_actor = false; in_prog = true; context = []; @@ -434,10 +434,14 @@ and check_AsyncCap env s at : T.typ * (T.con -> C.async_cap) = | C.CompositeCap c -> T.Con(c, []), fun c' -> C.CompositeAwaitCap c' | C.QueryCap c -> T.Con(c, []), fun _c' -> C.ErrorCap | C.ErrorCap -> - error env at "M0037" "misplaced %s; a query cannot contain an %s" s s - | C.NullCap -> error env at "M0037" "misplaced %s; try enclosing in an async function" s + local_error env at "M0037" "misplaced %s; a query cannot contain an %s" s s; + T.Con(C.bogus_cap,[]), fun c -> C.NullCap + | C.NullCap -> + local_error env at "M0037" "misplaced %s; try enclosing in an async function" s; + T.Con(C.bogus_cap,[]), fun c -> C.NullCap | C.CompositeAwaitCap _ -> - error env at "M0037" "misplaced %s; a composite query cannot contain an %s" s s + local_error env at "M0037" "misplaced %s; a composite query cannot contain an %s" s s; + T.Con(C.bogus_cap,[]), fun c -> C.NullCap and check_AwaitCap env s at = match env.async with @@ -447,9 +451,12 @@ and check_AwaitCap env s at = | C.QueryCap _ | C.CompositeCap _ -> - error env at "M0038" "misplaced %s; try enclosing in an async expression" s + local_error env at "M0038" "misplaced %s; try enclosing in an async expression" s; + T.Con(C.bogus_cap,[]) | C.ErrorCap - | C.NullCap -> error env at "M0038" "misplaced %s" s + | C.NullCap -> + local_error env at "M0038" "misplaced %s" s; + T.Con(C.bogus_cap,[]) and check_ErrorCap env s at = match env.async with @@ -459,8 +466,9 @@ and check_ErrorCap env s at = | C.AsyncCap _ | C.QueryCap _ | C.CompositeCap _ -> - error env at "M0039" "misplaced %s; try enclosing in an async expression or query function" s - | C.NullCap -> error env at "M0039" "misplaced %s" s + local_error env at "M0039" "misplaced %s; try enclosing in an async expression or query function" s + | C.NullCap -> + local_error env at "M0039" "misplaced %s" s and scope_of_env env = match env.async with @@ -2735,12 +2743,13 @@ and infer_dec_valdecs env dec : Scope.t = (* Programs *) -let infer_prog scope prog : (T.typ * Scope.t) Diag.result = +let infer_prog scope async_cap prog : (T.typ * Scope.t) Diag.result = Diag.with_message_store (fun msgs -> recover_opt (fun prog -> - let env = env_of_scope msgs scope in + let env0 = env_of_scope msgs scope in + let env = { env0 with async = async_cap } in let res = infer_block env prog.it prog.at in res ) prog diff --git a/src/mo_frontend/typing.mli b/src/mo_frontend/typing.mli index 290b0f7e7fc..a34a460a056 100644 --- a/src/mo_frontend/typing.mli +++ b/src/mo_frontend/typing.mli @@ -5,7 +5,7 @@ open Type open Scope val initial_scope : scope -val infer_prog : scope -> Syntax.prog -> (typ * scope) Diag.result +val infer_prog : scope -> Async_cap.async_cap -> Syntax.prog -> (typ * scope) Diag.result val check_lib : scope -> Syntax.lib -> scope Diag.result val check_actors : scope -> Syntax.prog list -> unit Diag.result diff --git a/src/mo_types/async_cap.ml b/src/mo_types/async_cap.ml index b6463d931cf..aa7c03498bf 100644 --- a/src/mo_types/async_cap.ml +++ b/src/mo_types/async_cap.ml @@ -12,4 +12,6 @@ type async_cap = let top_cap = Cons.fresh "$top-level" (T.Def([],T.Any)) +let bogus_cap = Cons.fresh "$bogus" (T.Def([],T.Non)) + let initial_cap () = AwaitCap top_cap diff --git a/src/pipeline/pipeline.ml b/src/pipeline/pipeline.ml index da9bb1d781e..0eb5f59813b 100644 --- a/src/pipeline/pipeline.ml +++ b/src/pipeline/pipeline.ml @@ -167,10 +167,23 @@ let print_deps (file : string) : unit = (* Checking *) -let infer_prog senv prog : (Type.typ * Scope.scope) Diag.result = +let async_cap_of_prog prog = + let open Syntax in + let open Source in + match (CompUnit.comp_unit_of_prog false prog).it.body.it with + | ActorClassU _ -> Async_cap.NullCap + | ActorU _ -> Async_cap.initial_cap() + | ModuleU _ -> assert false + | ProgU _ -> + if !Flags.compiled then + Async_cap.NullCap + else + Async_cap.initial_cap() + +let infer_prog senv async_cap prog : (Type.typ * Scope.scope) Diag.result = let filename = prog.Source.note.Syntax.filename in phase "Checking" filename; - let r = Typing.infer_prog senv prog in + let r = Typing.infer_prog senv async_cap prog in if !Flags.trace && !Flags.verbose then begin match r with | Ok ((_, scope), _) -> @@ -188,11 +201,12 @@ let infer_prog senv prog : (Type.typ * Scope.scope) Diag.result = let rec check_progs senv progs : Scope.scope Diag.result = match progs with | [] -> Diag.return senv - | p::ps -> + | prog::progs' -> let open Diag.Syntax in - let* _t, sscope = infer_prog senv p in + let async_cap = async_cap_of_prog prog in + let* _t, sscope = infer_prog senv async_cap prog in let senv' = Scope.adjoin senv sscope in - check_progs senv' ps + check_progs senv' progs' let check_lib senv lib : Scope.scope Diag.result = let filename = lib.Source.note.Syntax.filename in @@ -221,7 +235,7 @@ let check_builtin what src senv0 : Syntax.prog * stat_env = match parse_with Lexer.mode_priv lexer parse what with | Error es -> builtin_error "parsing" what es | Ok (prog, _ws) -> - match infer_prog senv0 prog with + match infer_prog senv0 Async_cap.NullCap prog with | Error es -> builtin_error "checking" what es | Ok ((_t, sscope), _ws) -> let senv1 = Scope.adjoin senv0 sscope in @@ -417,7 +431,7 @@ let load_decl parse_one senv : load_decl_result = let* parsed = parse_one in let* prog, libs = resolve_prog parsed in let* libs, senv' = chase_imports parse_file senv libs in - let* t, sscope = infer_prog senv' prog in + let* t, sscope = infer_prog senv' (Async_cap.(AwaitCap top_cap)) prog in let senv'' = Scope.adjoin senv' sscope in Diag.return (libs, prog, senv'', t, sscope) diff --git a/test/check-error-codes.py b/test/check-error-codes.py index afb663ef5cc..49adf765d95 100755 --- a/test/check-error-codes.py +++ b/test/check-error-codes.py @@ -32,7 +32,6 @@ "M0054", # cannot infer type of primitive expression. Could be internal "M0068", # mode-specific "M0084", # when would the return type be inferred? - "M0092", # async scopes "M0094", # hard to trigger (check_exp only applies with no type variables, but shared functions have type variables) "M0099", # hard to trigger (syntactic checks hit first) "M0100", # hard to trigger (syntactic checks hit first) diff --git a/test/fail/ok/await-in-actor.tc.ok b/test/fail/ok/await-in-actor.tc.ok index 2acb0c422fe..494972089d7 100644 --- a/test/fail/ok/await-in-actor.tc.ok +++ b/test/fail/ok/await-in-actor.tc.ok @@ -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 diff --git a/test/fail/ok/queries.tc.ok b/test/fail/ok/queries.tc.ok index d5a7a4d3adf..e6cff6d94c9 100644 --- a/test/fail/ok/queries.tc.ok +++ b/test/fail/ok/queries.tc.ok @@ -4,4 +4,10 @@ queries.mo:17.5-17.13: type error [M0188], send capability required, but not ava queries.mo:21.13-21.22: type error [M0188], send capability required, but not available (cannot call a `shared` function from a `query` function) queries.mo:22.5-22.20: type error [M0038], misplaced await +queries.mo:22.11-22.20: type error [M0188], send capability required, but not available + (cannot call a `shared` function from a `query` function) queries.mo:26.5-26.14: type error [M0037], misplaced async expression; a query cannot contain an async expression +queries.mo:26.5-26.14: type error [M0096], expression of type + async<$bogus> () +cannot produce expected type + () diff --git a/test/run-drun/issue-4297.mo b/test/run-drun/issue-4297.mo new file mode 100644 index 00000000000..3dce99a604e --- /dev/null +++ b/test/run-drun/issue-4297.mo @@ -0,0 +1 @@ +await async {}; diff --git a/test/run-drun/ok/aritybug.comp-ref.ok b/test/run-drun/ok/aritybug.comp-ref.ok index 34fdc366a21..103728f7bdb 100644 --- a/test/run-drun/ok/aritybug.comp-ref.ok +++ b/test/run-drun/ok/aritybug.comp-ref.ok @@ -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) diff --git a/test/run-drun/ok/aritybug.comp.ok b/test/run-drun/ok/aritybug.comp.ok index d4bd4b34fad..6ab94061154 100644 --- a/test/run-drun/ok/aritybug.comp.ok +++ b/test/run-drun/ok/aritybug.comp.ok @@ -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) diff --git a/test/run-drun/ok/inter-query.tc.ok b/test/run-drun/ok/inter-query.tc.ok index 5b1cc2afd30..d616acfe135 100644 --- a/test/run-drun/ok/inter-query.tc.ok +++ b/test/run-drun/ok/inter-query.tc.ok @@ -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) diff --git a/test/run-drun/ok/issue-1938-b.comp-ref.ok b/test/run-drun/ok/issue-1938-b.comp-ref.ok index 908468e7999..f27ab90c988 100644 --- a/test/run-drun/ok/issue-1938-b.comp-ref.ok +++ b/test/run-drun/ok/issue-1938-b.comp-ref.ok @@ -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 diff --git a/test/run-drun/ok/issue-1938-b.comp.ok b/test/run-drun/ok/issue-1938-b.comp.ok index b043c356828..f27ab90c988 100644 --- a/test/run-drun/ok/issue-1938-b.comp.ok +++ b/test/run-drun/ok/issue-1938-b.comp.ok @@ -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 diff --git a/test/run-drun/ok/issue-1938-c.comp-ref.ok b/test/run-drun/ok/issue-1938-c.comp-ref.ok index 863194bda58..fbb596e1e64 100644 --- a/test/run-drun/ok/issue-1938-c.comp-ref.ok +++ b/test/run-drun/ok/issue-1938-c.comp-ref.ok @@ -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 diff --git a/test/run-drun/ok/issue-1938-c.comp.ok b/test/run-drun/ok/issue-1938-c.comp.ok index a95bcac152a..fbb596e1e64 100644 --- a/test/run-drun/ok/issue-1938-c.comp.ok +++ b/test/run-drun/ok/issue-1938-c.comp.ok @@ -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 diff --git a/test/run-drun/ok/issue-1938.comp-ref.ok b/test/run-drun/ok/issue-1938.comp-ref.ok index 1061fe7670f..05e386770e2 100644 --- a/test/run-drun/ok/issue-1938.comp-ref.ok +++ b/test/run-drun/ok/issue-1938.comp-ref.ok @@ -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 diff --git a/test/run-drun/ok/issue-1938.comp.ok b/test/run-drun/ok/issue-1938.comp.ok index 50b4b3c0905..05e386770e2 100644 --- a/test/run-drun/ok/issue-1938.comp.ok +++ b/test/run-drun/ok/issue-1938.comp.ok @@ -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 diff --git a/test/run-drun/ok/issue-4297.comp-ref.ok b/test/run-drun/ok/issue-4297.comp-ref.ok new file mode 100644 index 00000000000..3b91d6b5190 --- /dev/null +++ b/test/run-drun/ok/issue-4297.comp-ref.ok @@ -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 diff --git a/test/run-drun/ok/issue-4297.comp-ref.ret.ok b/test/run-drun/ok/issue-4297.comp-ref.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/run-drun/ok/issue-4297.comp-ref.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/run-drun/ok/issue-4297.comp.ok b/test/run-drun/ok/issue-4297.comp.ok new file mode 100644 index 00000000000..3b91d6b5190 --- /dev/null +++ b/test/run-drun/ok/issue-4297.comp.ok @@ -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 diff --git a/test/run-drun/ok/issue-4297.comp.ret.ok b/test/run-drun/ok/issue-4297.comp.ret.ok new file mode 100644 index 00000000000..69becfa16f9 --- /dev/null +++ b/test/run-drun/ok/issue-4297.comp.ret.ok @@ -0,0 +1 @@ +Return code 1 diff --git a/test/run-drun/ok/scope-example-func-implicit.tc.ok b/test/run-drun/ok/scope-example-func-implicit.tc.ok index c4d5519ac5d..d150595b5d0 100644 --- a/test/run-drun/ok/scope-example-func-implicit.tc.ok +++ b/test/run-drun/ok/scope-example-func-implicit.tc.ok @@ -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 diff --git a/test/run-drun/ok/scope-example-func.tc.ok b/test/run-drun/ok/scope-example-func.tc.ok index 330ab80a99f..1e72db69880 100644 --- a/test/run-drun/ok/scope-example-func.tc.ok +++ b/test/run-drun/ok/scope-example-func.tc.ok @@ -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 diff --git a/test/run-drun/ok/unsupported-more.comp-ref.ok b/test/run-drun/ok/unsupported-more.comp-ref.ok index a363f3be04d..ddecbbe0fae 100644 --- a/test/run-drun/ok/unsupported-more.comp-ref.ok +++ b/test/run-drun/ok/unsupported-more.comp-ref.ok @@ -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 diff --git a/test/run-drun/ok/unsupported-more.comp.ok b/test/run-drun/ok/unsupported-more.comp.ok index 9798b6bcb28..ddecbbe0fae 100644 --- a/test/run-drun/ok/unsupported-more.comp.ok +++ b/test/run-drun/ok/unsupported-more.comp.ok @@ -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 diff --git a/test/run-drun/ok/unsupported.comp-ref.ok b/test/run-drun/ok/unsupported.comp-ref.ok index bba396c0542..5377b5cb83c 100644 --- a/test/run-drun/ok/unsupported.comp-ref.ok +++ b/test/run-drun/ok/unsupported.comp-ref.ok @@ -1,3 +1,5 @@ +unsupported.mo:2.1-33.2: type error [M0038], misplaced await +unsupported.mo:2.1-33.2: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:4.14-4.50: type error [M0126], a shared function cannot be private (This is a limitation of the current version and flag -ref-system-api.) unsupported.mo:36.26-36.29: type error [M0077], a shared function is only allowed as a public field of an actor @@ -6,10 +8,16 @@ unsupported.mo:50.3-50.35: type error [M0139], inner actor classes are not suppo (This is a limitation of the current version and flag -ref-system-api.) unsupported.mo:54.3-54.42: type error [M0139], inner actor classes are not supported yet; any actor class must come last in your program (This is a limitation of the current version and flag -ref-system-api.) +unsupported.mo:58.45-58.53: type error [M0038], misplaced await +unsupported.mo:58.45-58.53: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:58.45-58.53: type error [M0069], non-toplevel actor; an actor can only be declared at the toplevel of a program (This is a limitation of the current version and flag -ref-system-api.) +unsupported.mo:62.39-62.47: type error [M0038], misplaced await +unsupported.mo:62.39-62.47: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:62.39-62.47: type error [M0069], non-toplevel actor; an actor can only be declared at the toplevel of a program (This is a limitation of the current version and flag -ref-system-api.) +unsupported.mo:66.1-66.25: type error [M0038], misplaced await +unsupported.mo:66.1-66.25: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:72.34-72.37: 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.) unsupported.mo:73.27-73.30: type error [M0077], a shared function is only allowed as a public field of an actor diff --git a/test/run-drun/ok/unsupported.comp.ok b/test/run-drun/ok/unsupported.comp.ok index 9e6f58ad963..0133928e5f8 100644 --- a/test/run-drun/ok/unsupported.comp.ok +++ b/test/run-drun/ok/unsupported.comp.ok @@ -1,3 +1,5 @@ +unsupported.mo:2.1-33.2: type error [M0038], misplaced await +unsupported.mo:2.1-33.2: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:4.14-4.50: type error [M0126], a shared function cannot be private (This is a limitation of the current version.) unsupported.mo:36.26-36.29: type error [M0077], a shared function is only allowed as a public field of an actor @@ -6,10 +8,16 @@ unsupported.mo:50.3-50.35: type error [M0139], inner actor classes are not suppo (This is a limitation of the current version.) unsupported.mo:54.3-54.42: type error [M0139], inner actor classes are not supported yet; any actor class must come last in your program (This is a limitation of the current version.) +unsupported.mo:58.45-58.53: type error [M0038], misplaced await +unsupported.mo:58.45-58.53: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:58.45-58.53: type error [M0069], non-toplevel actor; an actor can only be declared at the toplevel of a program (This is a limitation of the current version.) +unsupported.mo:62.39-62.47: type error [M0038], misplaced await +unsupported.mo:62.39-62.47: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:62.39-62.47: type error [M0069], non-toplevel actor; an actor can only be declared at the toplevel of a program (This is a limitation of the current version.) +unsupported.mo:66.1-66.25: type error [M0038], misplaced await +unsupported.mo:66.1-66.25: type error [M0037], misplaced async expression; try enclosing in an async function unsupported.mo:72.34-72.37: type error [M0077], a shared function is only allowed as a public field of an actor (This is a limitation of the current version.) unsupported.mo:73.27-73.30: type error [M0077], a shared function is only allowed as a public field of an actor