Skip to content

Commit 210ead3

Browse files
committed
Support tuple annotations.
1 parent fff71bb commit 210ead3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Exception.re

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,23 @@ let traverseAst = {
276276
};
277277
let raisesAnnotationPayload =
278278
vb.vb_attributes |> Annotation.getAttributePayload((==)("raises"));
279-
let exceptions =
280-
switch (raisesAnnotationPayload) {
281-
| Some(Annotation.StringPayload(s) | Annotation.ConstructPayload(s)) =>
279+
let rec getExceptions = payload =>
280+
switch (payload) {
281+
| Annotation.StringPayload(s) => Exn.fromString(s) |> ExnSet.singleton
282+
| Annotation.ConstructPayload(s) =>
282283
Exn.fromString(s) |> ExnSet.singleton
284+
| Annotation.TuplePayload(tuple) =>
285+
tuple
286+
|> List.map(payload => payload |> getExceptions |> ExnSet.elements)
287+
|> List.concat
288+
|> ExnSet.of_list
283289
| _ => ExnSet.empty
284290
};
291+
let exceptions =
292+
switch (raisesAnnotationPayload) {
293+
| None => ExnSet.empty
294+
| Some(payload) => payload |> getExceptions
295+
};
285296
Hashtbl.replace(valueBindingsTable, Ident.name(id), exceptions);
286297
let res = super.value_binding(self, vb);
287298
let raiseSet = currentEvents^ |> Event.combine;

0 commit comments

Comments
 (0)