Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* motoko (`moc`)

* Fix for #5618 (compiling dotted `await`s) (#5622).

* Improved type inference of the record update syntax (#5625).

* New flag `--error-recovery` to enable reporting of multiple syntax errors (#5632).
Expand Down
11 changes: 8 additions & 3 deletions src/mo_def/syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,16 @@ let contextual_dot_args e1 e2 dot_note =
let arity = match dot_note.note.note_typ with
| T.Func(_, _, _, args, _) -> List.length args
| _ -> raise (Invalid_argument "non-function type in contextual dot note") in
let effect eff =
match (e1.note.note_eff, eff) with
| T.Triv, T.Triv -> T.Triv
| _, _ -> T.Await
in
let args = match e2 with
| { it = TupE []; at; note = { note_eff;_ } } ->
{ it = e1.it; at; note = { note_eff; note_typ = e1.note.note_typ } }
{ it = e1.it; at; note = { note_eff = effect note_eff; note_typ = e1.note.note_typ } }
| { it = TupE exps; at; note = { note_eff; note_typ = T.Tup ts } } when arity <> 2 ->
{ it = TupE (e1::exps); at; note = { note_eff; note_typ = T.Tup (e1.note.note_typ::ts) } }
{ it = TupE (e1::exps); at; note = { note_eff = effect note_eff; note_typ = T.Tup (e1.note.note_typ::ts) } }
| { at; note = { note_eff; _ }; _ } ->
{ it = TupE ([e1; e2]); at; note = { note_eff; note_typ = T.Tup ([e1.note.note_typ; e2.note.note_typ]) } }
{ it = TupE ([e1; e2]); at; note = { note_eff = effect note_eff; note_typ = T.Tup ([e1.note.note_typ; e2.note.note_typ]) } }
in args
5 changes: 4 additions & 1 deletion src/mo_frontend/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2667,8 +2667,11 @@ and infer_callee env exp =
mk_error env
| Ok { module_name; path; func_ty; inst; _ } ->
note := Some path;
if not env.pre then
if not env.pre then begin
check_exp env func_ty path;
let note_eff = A.infer_effect_exp exp in
exp.note <- {note_typ = exp.note.note_typ; note_eff}
end;
func_ty, Some (exp1, t1, id.it, inst)
end
| _ ->
Expand Down
11 changes: 11 additions & 0 deletions test/run-drun/await-dot.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
persistent actor {

module Nat {
public func id(self : Nat) : Nat { self };
};

public func go () {
ignore (await (async 1)).id() == 1;
}

}
2 changes: 2 additions & 0 deletions test/run-drun/ok/await-dot.drun-run.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000