Skip to content

Commit

Permalink
WIP: prepare for timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif committed Dec 6, 2024
1 parent a0d475a commit c9bd84f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 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 @@ -208,4 +208,5 @@ let error_codes : (string * string option) list =
"M0202", None; (* parenthetical note must be applied to a message send *)
"M0203", None; (* parenthetical note has no attributes *)
"M0204", Some([%blob "lang_utils/error_codes/M0204.md"]); (* Unrecognised attribute in parenthetical note *)
"M0205", None; (* `timeout` attribute in parenthetical note must be of type `Nat32` *)
]
9 changes: 7 additions & 2 deletions src/mo_frontend/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2567,13 +2567,18 @@ and validate_parenthetical env typ_opt = function
let attrs = infer_exp env par in
let [@warning "-8"] T.Object, attrs_flds = T.as_obj attrs in
if attrs_flds = [] then warn env par.at "M0203" "redundant empty parenthetical note";
let unrecognised = List.(filter (fun {T.lab; _} -> lab <> "cycles") attrs_flds |> map (fun {T.lab; _} -> lab)) in
let unrecognised = List.(filter (fun {T.lab; _} -> lab <> "cycles" && lab <> "timeout") attrs_flds |> map (fun {T.lab; _} -> lab)) in
if unrecognised <> [] then warn env par.at "M0204" "unrecognised attribute %s in parenthetical note" (List.hd unrecognised);
let cyc = List.(filter (fun {T.lab; _} -> lab = "cycles") attrs_flds) in
if cyc <> [] && not T.(sub (List.hd cyc).typ nat) then
local_error env par.at "M0201"
"expected Nat type for attribute cycles, but it has type%a"
display_typ_expand (List.hd cyc).T.typ
display_typ_expand (List.hd cyc).T.typ;
let timeout = List.(filter (fun {T.lab; _} -> lab = "timeout") attrs_flds) in
if timeout <> [] && not T.(sub (List.hd timeout).typ nat) then
local_error env par.at "M0205"
"expected Nat32 type for attribute timeout, but it has type%a"
display_typ_expand (List.hd timeout).T.typ

and check_system_fields env sort scope tfs dec_fields =
List.iter (fun df ->
Expand Down
2 changes: 1 addition & 1 deletion test/run-drun/ok/par.tc.ok
Original file line number Diff line number Diff line change
@@ -1 +1 @@
par.mo:53.9-53.67: warning [M0204], unrecognised attribute timeout in parenthetical note
par.mo:53.9-53.67: warning [M0204], unrecognised attribute yeah in parenthetical note

0 comments on commit c9bd84f

Please sign in to comment.