Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions changes/as-payload-error-lists-float-bigint.polish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- List floats and bigints in the error for an invalid `@as` payload, since `@as` accepts them.
6 changes: 3 additions & 3 deletions compiler/ml/UntaggedVariants.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ is the number `1`.
- Implementation: `ast_untagged_variants.ml:runtime_tag_of_parsetree`,
`process_constructor_tag`.
- Tests: fixtures `UntaggedInvalidVariantAsAnnotation.res`
("A variant case annotation @as(...) must be a string, integer, boolean,
null, or undefined."), `VariantAsIntegerOutOfRange.res`,
("A variant case annotation @as(...) must be a string, integer, float,
bigint, boolean, null, or undefined."), `VariantAsIntegerOutOfRange.res`,
`UntaggedDuplicatedBsAs.res`; `spec_test` rule 2;
`tests/tests/src/unboxed_variant_fold_test.res` (`wide`).

Expand Down Expand Up @@ -140,7 +140,7 @@ The type checker rejects an untagged variant, with
| Condition | Reason | Fixture |
| --- | --- | --- |
| two object cases | At most one case can be an object type. | `UntaggedAtMostOneObject.res` |
| two cases of one instance class (arrays and tuples share `Array`) | At most one case can be a C type. | `UntaggedAtMostOneInstance.res`, `UntaggedTupleAndArray.res` |
| two cases of one instance class (arrays and tuples share `Array`) | At most one case can be a C type; for `Array`, an array or tuple type. | `UntaggedAtMostOneInstance.res`, `UntaggedTupleAndArray.res` |
| two function cases | At most one case can be a function type. | `UntaggedAtMostOneFunction.res` |
| two string cases | At most one case can be a string type. | `UntaggedAtMostOneString.res` |
| two number cases (`int` and `float` count together) | At most one case can be a number type (int or float). | `UntaggedAtMostOneNumber.res` |
Expand Down
4 changes: 2 additions & 2 deletions compiler/ml/ast_untagged_variants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let report_error ppf =
function
| InvalidVariantAsAnnotation ->
fprintf ppf
"A variant case annotation @as(...) must be a string, integer, boolean, \
null, or undefined."
"A variant case annotation @as(...) must be a string, integer, float, \
bigint, boolean, null, or undefined."
| VariantAsIntegerOutOfRange value ->
fprintf ppf
"The integer %s in this variant case's @as annotation is out of range."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
1 │ type t = | @as(foo) A | B
2 │

A variant case annotation @as(...) must be a string, integer, boolean, null, or undefined.
A variant case annotation @as(...) must be a string, integer, float, bigint, boolean, null, or undefined.
Loading