Skip to content

Commit

Permalink
fix M0202
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif committed Nov 29, 2024
1 parent 8a7c490 commit 05eb145
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/lang_utils/error_codes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,5 @@ let error_codes : (string * string option) list =
"M0199", Some([%blob "lang_utils/error_codes/M0199.md"]); (* Deprecate experimental stable memory *)
"M0200", Some([%blob "lang_utils/error_codes/M0200.md"]); (* Unrecognised attribute in parenthetical note *)
"M0201", None; (* `cycle` attribute in parenthetical note must be of type `Nat` *)
"M0202", None; (* parenthetical note must be applied to a message send *)
]
8 changes: 3 additions & 5 deletions src/mo_frontend/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1981,14 +1981,14 @@ and check_exp' env0 t exp : T.typ =
in
check_exp_strong (adjoin_vals env' ve2) t2 exp;
t
| CallE (_FIXME, exp1, inst, exp2), _ ->
ignore (Option.map (infer_exp env) _FIXME);
| CallE (par_opt, exp1, inst, exp2), _ ->
let t' = infer_call env exp1 inst exp2 exp.at (Some t) in
if not (T.sub t' t) then
local_error env0 exp.at "M0096"
"expression of type%a\ncannot produce expected type%a"
display_typ_expand t'
display_typ_expand t;
if not env.pre then validate_parenthetical env (Some exp1.note.note_typ) par_opt;
t'
| TagE (id, exp1), T.Variant fs when List.exists (fun T.{lab; _} -> lab = id.it) fs ->
let {T.typ; _} = List.find (fun T.{lab; typ;_} -> lab = id.it) fs in
Expand Down Expand Up @@ -2560,12 +2560,10 @@ and validate_parenthetical env typ_opt = function
begin match typ_opt with
| Some fun_ty when T.is_func fun_ty ->
let s, _, _, _, ts2 = T.as_func fun_ty in
local_error env par.at "M02041"
"result has types %a" display_typ_list ts2;
begin match ts2 with
| _ when T.is_shared_sort s -> ();
| [cod] when T.is_async cod -> ();
| _ -> assert false; warn env par.at "M0202" "unexpected parenthetical note on a non-send call";
| _ -> warn env par.at "M0202" "unexpected parenthetical note on a non-send call";
end
| _ -> ()
end;
Expand Down
4 changes: 2 additions & 2 deletions test/fail/cycle-type.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ actor {
let defaults = { moot = 9 };
await (defaults with cycles = 'C') a.foo();
await (defaults with cycles = "Can't") async ();
func nonSend() : async Nat = async 42;
ignore await (defaults with cycles = 0) nonSend();
func nonSend() : Nat = 42;
ignore (with) nonSend();
}
}
9 changes: 5 additions & 4 deletions test/fail/ok/cycle-type.tc.ok
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cycle-type.mo:4.40-4.47: warning [M0200], unrecognised attribute moot in parenthetical note
cycle-type.mo:4.40-4.47: type error [M0201], expected Nat type for attribute cycles, but it has type
cycle-type.mo:4.44-4.51: warning [M0200], unrecognised attribute moot in parenthetical note
cycle-type.mo:4.44-4.51: type error [M0201], expected Nat type for attribute cycles, but it has type
Char
cycle-type.mo:5.44-5.52: warning [M0200], unrecognised attribute moot in parenthetical note
cycle-type.mo:5.44-5.52: type error [M0201], expected Nat type for attribute cycles, but it has type
cycle-type.mo:5.48-5.56: warning [M0200], unrecognised attribute moot in parenthetical note
cycle-type.mo:5.48-5.56: type error [M0201], expected Nat type for attribute cycles, but it has type
Text
cycle-type.mo:7.23-7.32: warning [M0202], unexpected parenthetical note on a non-send call

0 comments on commit 05eb145

Please sign in to comment.