Skip to content

Commit

Permalink
Invalid label to malformed
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Feb 7, 2025
1 parent 9d54d9f commit c691d45
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
8 changes: 4 additions & 4 deletions src/haz3lcore/statics/Info.re
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ type error_common =
| Inconsistent(error_inconsistent)
/* The error on a specific duplicate label */
| DuplicateLabel(LabeledTuple.label, Typ.t)
/* Tuple/TupLabel contains invalid labels, duplicate labels, and/or unexpected labels */
/* Tuple/TupLabel contains malformed labels, duplicate labels, and/or unexpected labels */
| TupleLabelError({
invalid_labels: list(Any.t),
malformed_labels: list(Any.t),
duplicate_labels: list(LabeledTuple.label),
unexpected_labels: list(LabeledTuple.label),
typ: Typ.t,
Expand Down Expand Up @@ -419,7 +419,7 @@ let rec status_common =
| (UnexpectedLabel(label), _) => InHole(NoType(UnexpectedLabel(label)))
| (
TupleLabelError({
invalid_labels,
malformed_labels,
duplicate_labels,
unexpected_labels,
typ,
Expand All @@ -428,7 +428,7 @@ let rec status_common =
) =>
InHole(
TupleLabelError({
invalid_labels,
malformed_labels,
duplicate_labels,
unexpected_labels,
typ,
Expand Down
6 changes: 3 additions & 3 deletions src/haz3lcore/statics/Self.re
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ type t =
| BadLabel(Any.t) /* TupLabel label component is not a valid Label*/
| UnexpectedLabel(LabeledTuple.label) /* Unexpected label in a labeled tuple */
| TupleLabelError({
invalid_labels: list(Any.t),
malformed_labels: list(Any.t), // Labels that are not of the right syntactic form
duplicate_labels: list(LabeledTuple.label),
unexpected_labels: list(LabeledTuple.label),
unexpected_labels: list(LabeledTuple.label), // Labels that are present but aren't present in the analyzed type
typ: Typ.t,
}) /* Tuple/TupLabel contains invalid labels, duplicate labels, and/or unexpected labels */
}) /* Tuple/TupLabel contains malformed labels, duplicate labels, and/or unexpected labels */
| IsMulti /* Multihole, treated as hole */
| IsConstructor({
name: Constructor.t,
Expand Down
32 changes: 16 additions & 16 deletions src/haz3lcore/statics/Statics.re
Original file line number Diff line number Diff line change
Expand Up @@ -452,21 +452,21 @@ and uexp_to_info_map =
)
| InHole(Common(NoType(UnexpectedLabel(name)))) =>
Self.TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: [],
unexpected_labels: [name],
typ: TupLabel(Label(name) |> Typ.temp, e.ty) |> Typ.temp,
})
| InHole(Common(DuplicateLabel(name, _))) =>
Self.TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: [name],
unexpected_labels: [],
typ: TupLabel(Label(name) |> Typ.temp, e.ty) |> Typ.temp,
})
| InHole(_) =>
Self.TupleLabelError({
invalid_labels: [Exp(label)],
malformed_labels: [Exp(label)],
duplicate_labels: [],
unexpected_labels: [],
typ: TupLabel(Unknown(Internal) |> Typ.temp, e.ty) |> Typ.temp,
Expand Down Expand Up @@ -538,21 +538,21 @@ and uexp_to_info_map =
);
let ty_list = List.map(Info.exp_ty, es');

let (invalid_labels, duplicate_labels, unexpected_labels) =
let (malformed_labels, duplicate_labels, unexpected_labels) =
List.fold_left(
((a, b, c), e: Info.exp) => {
switch (e.status) {
| InHole(
Common(
TupleLabelError({
invalid_labels,
malformed_labels,
duplicate_labels,
unexpected_labels,
_,
}),
),
) => (
a @ invalid_labels,
a @ malformed_labels,
b @ duplicate_labels,
c @ unexpected_labels,
)
Expand All @@ -566,12 +566,12 @@ and uexp_to_info_map =
let ty_list = Typ.remove_duplicate_labels(~duplicate_labels, ty_list);

let self =
List.is_empty(invalid_labels)
List.is_empty(malformed_labels)
&& List.is_empty(duplicate_labels)
&& List.is_empty(unexpected_labels)
? Self.Just(Prod(ty_list) |> Typ.temp)
: Self.TupleLabelError({
invalid_labels,
malformed_labels,
duplicate_labels,
unexpected_labels,
typ: Prod(ty_list) |> Typ.temp,
Expand Down Expand Up @@ -1303,21 +1303,21 @@ and upat_to_info_map =
)
| InHole(Common(NoType(UnexpectedLabel(name)))) =>
Self.TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: [],
unexpected_labels: [name],
typ: TupLabel(Label(name) |> Typ.temp, p.ty) |> Typ.temp,
})
| InHole(Common(DuplicateLabel(name, _))) =>
Self.TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: [name],
unexpected_labels: [],
typ: TupLabel(Label(name) |> Typ.temp, p.ty) |> Typ.temp,
})
| InHole(_) =>
Self.TupleLabelError({
invalid_labels: [Pat(label)],
malformed_labels: [Pat(label)],
duplicate_labels: [],
unexpected_labels: [],
typ: TupLabel(Unknown(Internal) |> Typ.temp, p.ty) |> Typ.temp,
Expand Down Expand Up @@ -1399,21 +1399,21 @@ and upat_to_info_map =
modes,
);

let (invalid_labels, duplicate_labels, unexpected_labels) =
let (malformed_labels, duplicate_labels, unexpected_labels) =
List.fold_left(
((a, b, c), e: Info.pat) => {
switch (e.status) {
| InHole(
Common(
TupleLabelError({
invalid_labels,
malformed_labels,
duplicate_labels,
unexpected_labels,
_,
}),
),
) => (
a @ invalid_labels,
a @ malformed_labels,
b @ duplicate_labels,
c @ unexpected_labels,
)
Expand All @@ -1424,12 +1424,12 @@ and upat_to_info_map =
info_pats,
);
let self =
List.is_empty(invalid_labels)
List.is_empty(malformed_labels)
&& List.is_empty(duplicate_labels)
&& List.is_empty(unexpected_labels)
? Self.Just(Prod(tys) |> Typ.temp)
: Self.TupleLabelError({
invalid_labels,
malformed_labels,
duplicate_labels,
unexpected_labels,
typ: Prod(tys) |> Typ.temp,
Expand Down
2 changes: 1 addition & 1 deletion src/haz3lweb/app/explainthis/data/TupLabelTyp.re
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let labeled_exps_coloring_ids =
(Piece.id(p), typ_id),
];
let labeled_typ: form = {
let explanation = "Assigns a [*label*](%s) to a [*type*](%s) within a Tuple type. Labeled types cannot exist outside of a Product. Labeled types that are not contained within a Product are autmatically converted into a singleton product.";
let explanation = "Assigns a [*label*](%s) to a [*type*](%s) within a Tuple type. Labeled types cannot exist outside of a Tuple. Labeled types that are not contained within a Tuple are autmatically converted into a singleton tuple.";
{
id: LabeledTyp,
syntactic_form: [lab, labeled_typ(), p],
Expand Down
18 changes: 9 additions & 9 deletions src/haz3lweb/app/inspector/CursorInspector.re
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ let common_err_view =
view_type(Prod([]) |> Typ.fresh),
]
| NoType(BadLabel(label)) => [
text("An invalid Label: "),
text("Malformed Label: "),
view_any(label),
]
| NoType(FreeConstructor(name)) => [code(name), text("not found")]
| NoType(WantTuple) => [
text("Invalid Dot Operation: requires tuple for first argument"),
text("Requires tuple for first argument"),
]
| NoType(LabelNotFound(name, labels)) => [
text("Invalid Dot Operation: label "),
text("Label "),
code(name),
text(" not found in tuple's labels: "),
...List.map(code, labels),
Expand All @@ -153,17 +153,17 @@ let common_err_view =
code(name),
]
| TupleLabelError({
invalid_labels,
malformed_labels,
duplicate_labels,
unexpected_labels,
_,
}) =>
(
List.is_empty(invalid_labels)
List.is_empty(malformed_labels)
? []
: [
text("Invalid labels: "),
...List.map(view_any, invalid_labels),
text("Malformed labels: "),
...List.map(view_any, malformed_labels),
]
)
@ (
Expand All @@ -182,7 +182,7 @@ let common_err_view =
...List.map(code, unexpected_labels),
]
)
| DuplicateLabel(name, _) => [text("Duplicated Label:"), code(name)]
| DuplicateLabel(name, _) => [text("Duplicate Label:"), code(name)]
| Inconsistent(WithArrow(typ)) => [
text(":"),
view_type(typ) |> code_box_container,
Expand Down Expand Up @@ -440,7 +440,7 @@ let typ_err_view = (~globals, ok: Info.error_typ) => {
text("Duplicate labels within a tuple: "),
...List.map(code, labels),
]
| Duplicate(name, _) => [text("Duplicated Label: "), code(name)]
| Duplicate(name, _) => [text("Duplicate Label: "), code(name)]
| DuplicateConstructor(name) => [
view_type(Var(name) |> Typ.fresh) |> code_box_container,
text("already used in this sum"),
Expand Down
2 changes: 1 addition & 1 deletion test/Test_MakeTerm.re
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ let tests = (
{|let x : (l=Int, l2=String) = (l=32, l2="") in x|},
)
),
test_case("Invalid label in singleton tuple", `Quick, () =>
test_case("Malformed label in singleton tuple", `Quick, () =>
exp_check(
Parens(
Tuple([
Expand Down
22 changes: 11 additions & 11 deletions test/Test_Statics.re
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let eq_info_error_exp = (a: Info.error_exp, b: Info.error_exp) => {
) =>
Typ.fast_equal(a1, b1) && Typ.fast_equal(a2, b2)
| (Common(TupleLabelError(err)), Common(TupleLabelError(err'))) =>
List.equal(Any.fast_equal, err.invalid_labels, err'.invalid_labels)
List.equal(Any.fast_equal, err.malformed_labels, err'.malformed_labels)
&& List.equal(String.equal, err.duplicate_labels, err'.duplicate_labels)
&& List.equal(
String.equal,
Expand Down Expand Up @@ -729,7 +729,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: ["a", "a"],
unexpected_labels: [],
typ:
Expand All @@ -753,7 +753,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: ["a"],
unexpected_labels: [],
typ:
Expand All @@ -770,7 +770,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: ["a"],
unexpected_labels: [],
typ:
Expand Down Expand Up @@ -828,7 +828,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [Exp(l1)],
malformed_labels: [Exp(l1)],
duplicate_labels: [],
unexpected_labels: [],
typ:
Expand All @@ -852,7 +852,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [Exp(l1)],
malformed_labels: [Exp(l1)],
unexpected_labels: [],
duplicate_labels: [],
typ:
Expand Down Expand Up @@ -907,7 +907,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [Exp(l1)],
malformed_labels: [Exp(l1)],
unexpected_labels: [],
duplicate_labels: [],
typ:
Expand All @@ -933,7 +933,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [Exp(l1)],
malformed_labels: [Exp(l1)],
unexpected_labels: [],
duplicate_labels: [],
typ:
Expand All @@ -953,7 +953,7 @@ let tests = (

check(
option(testable_info_error_exp),
"Label Error invalid label",
"Label Error malformed label",
Some(Common(NoType(BadLabel(Exp(l1))))),
Statics.get_error_at(s, IdTagged.rep_id(l1)),
);
Expand Down Expand Up @@ -1007,7 +1007,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: [],
unexpected_labels: ["c"],
typ: TupLabel(Label("c") |> Typ.temp, int_ty) |> Typ.temp,
Expand All @@ -1028,7 +1028,7 @@ let tests = (
Some(
Common(
TupleLabelError({
invalid_labels: [],
malformed_labels: [],
duplicate_labels: [],
unexpected_labels: ["c"],
typ:
Expand Down

0 comments on commit c691d45

Please sign in to comment.