Skip to content

Commit df849f2

Browse files
committed
Remove needless line-move noise from the diff
Reviewed the whole diff vs master and reverted reorderings that were not real changes, so the review shows only the actual edits in place: - typemod.ml: reverted entirely to master. Its only diff was two report_error arms (Cannot_eliminate_dependency, With_changes_module_alias) reordered — pure cosmetic churn, both still raised, no content change. - typecore.ml: moved list_labels/list_labels_aux back to their original spot (after type_approx, before check_univars) with the original comment. I had re-added them before lower_args when restoring, creating a spurious delete+add pair. - bs_syntaxerr.ml/.mli: restored to master and re-applied only the intended change in place — Misplaced_label_syntax had been relocated to the end of the error type and pp_error; now it stays in its original position and the only diff is the message typo fix ("support" -> "supported"), which the fixture already expects. env.ml/.mli were already byte-identical to master. No behavioral change; build + format clean, super_errors suite green.
1 parent baedeb3 commit df849f2

4 files changed

Lines changed: 37 additions & 26 deletions

File tree

compiler/frontend/bs_syntaxerr.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ type untagged_variant = OnlyOneUnknown | AtMostOneObject | AtMostOneArray
2626

2727
type error =
2828
| Unsupported_predicates
29+
| Conflict_bs_bs_this_bs_meth
2930
| Duplicated_bs_deriving
3031
| Conflict_attributes
3132
| Expect_int_literal
3233
| Expect_string_literal
3334
| Expect_int_or_string_or_json_literal
35+
| Unhandled_poly_type
3436
| Invalid_underscore_type_in_external
3537
| Invalid_bs_string_type
3638
| Invalid_bs_int_type
@@ -42,15 +44,19 @@ type error =
4244
*)
4345
| Not_supported_directive_in_bs_return
4446
| Expect_opt_in_bs_return_to_opt
47+
| Misplaced_label_syntax
4548
| Optional_in_uncurried_bs_attribute
4649
| Bs_this_simple_pattern
4750
| Experimental_feature_not_enabled of Experimental_features.feature
4851
| LetUnwrap_not_supported_in_position of [`Toplevel | `Unsupported_type]
49-
| Misplaced_label_syntax
5052

5153
let pp_error fmt err =
5254
Format.pp_print_string fmt
5355
(match err with
56+
| Misplaced_label_syntax -> "Label syntax is not supported in this position"
57+
(*
58+
let fn x = ((##) x ~hi) ~lo:1 ~hi:2
59+
*)
5460
| Optional_in_uncurried_bs_attribute ->
5561
"Uncurried function doesn't support optional arguments yet"
5662
| Expect_opt_in_bs_return_to_opt ->
@@ -59,12 +65,15 @@ let pp_error fmt err =
5965
| Not_supported_directive_in_bs_return -> "Not supported return directive"
6066
| Illegal_attribute -> "Illegal attributes"
6167
| Unsupported_predicates -> "unsupported predicates"
68+
| Conflict_bs_bs_this_bs_meth ->
69+
"%@this and %@bs can not be applied at the same time"
6270
| Duplicated_bs_deriving -> "duplicate @deriving attribute"
6371
| Conflict_attributes -> "conflicting attributes "
6472
| Expect_string_literal -> "expect string literal "
6573
| Expect_int_literal -> "expect int literal "
6674
| Expect_int_or_string_or_json_literal ->
6775
"expect int, string literal or json literal {json|text here|json} "
76+
| Unhandled_poly_type -> "Unhandled poly type"
6877
| Invalid_underscore_type_in_external ->
6978
"_ is not allowed in combination with external optional type"
7079
| Invalid_bs_string_type -> "Not a valid type for %@string"
@@ -87,8 +96,7 @@ let pp_error fmt err =
8796
| `Toplevel -> "`let?` is not allowed for top-level bindings."
8897
| `Unsupported_type ->
8998
"`let?` is only supported in let bindings targeting the `result` or \
90-
`option` type.")
91-
| Misplaced_label_syntax -> "Label syntax is not supported in this position")
99+
`option` type."))
92100

93101
type exn += Error of Location.t * error
94102

compiler/frontend/bs_syntaxerr.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ type untagged_variant = OnlyOneUnknown | AtMostOneObject | AtMostOneArray
2626

2727
type error =
2828
| Unsupported_predicates
29+
| Conflict_bs_bs_this_bs_meth
2930
| Duplicated_bs_deriving
3031
| Conflict_attributes
3132
| Expect_int_literal
3233
| Expect_string_literal
3334
| Expect_int_or_string_or_json_literal
35+
| Unhandled_poly_type
3436
| Invalid_underscore_type_in_external
3537
| Invalid_bs_string_type
3638
| Invalid_bs_int_type
@@ -42,11 +44,11 @@ type error =
4244
*)
4345
| Not_supported_directive_in_bs_return
4446
| Expect_opt_in_bs_return_to_opt
47+
| Misplaced_label_syntax
4548
| Optional_in_uncurried_bs_attribute
4649
| Bs_this_simple_pattern
4750
| Experimental_feature_not_enabled of Experimental_features.feature
4851
| LetUnwrap_not_supported_in_position of [`Toplevel | `Unsupported_type]
49-
| Misplaced_label_syntax
5052

5153
val err : Location.t -> error -> 'a
5254

compiler/ml/typecore.ml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,19 @@ let rec type_approx env sexp =
19891989
ty2
19901990
| _ -> newvar ()
19911991
1992+
(* List labels in a function type, and whether return type is a variable *)
1993+
let rec list_labels_aux env visited ls ty_fun =
1994+
let ty = expand_head env ty_fun in
1995+
if List.memq ty visited then (List.rev ls, false)
1996+
else
1997+
match ty.desc with
1998+
| Tarrow (arg, ty_res, _, arity) when arity = None || visited = [] ->
1999+
list_labels_aux env (ty :: visited) (arg.lbl :: ls) ty_res
2000+
| _ -> (List.rev ls, is_Tvar ty)
2001+
2002+
let list_labels env ty =
2003+
wrap_trace_gadt_instances env (list_labels_aux env [] []) ty
2004+
19922005
(* Check that all univars are safe in a type *)
19932006
let check_univars env expans kind exp ty_expected vars =
19942007
if expans && not (is_nonexpansive exp) then
@@ -2250,18 +2263,6 @@ let is_ignore ~env ~arity funct =
22502263
with Unify _ -> false)
22512264
| _ -> false
22522265
2253-
let rec list_labels_aux env visited ls ty_fun =
2254-
let ty = expand_head env ty_fun in
2255-
if List.memq ty visited then (List.rev ls, false)
2256-
else
2257-
match ty.desc with
2258-
| Tarrow (arg, ty_res, _, arity) when arity = None || visited = [] ->
2259-
list_labels_aux env (ty :: visited) (arg.lbl :: ls) ty_res
2260-
| _ -> (List.rev ls, is_Tvar ty)
2261-
2262-
let list_labels env ty =
2263-
wrap_trace_gadt_instances env (list_labels_aux env [] []) ty
2264-
22652266
let rec lower_args env seen ty_fun =
22662267
let ty = expand_head env ty_fun in
22672268
if List.memq ty seen then ()

compiler/ml/typemod.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,11 @@ let report_error ppf = function
18181818
fprintf ppf "@[This module is not a functor; it has type@ %a@]" modtype mty
18191819
| Not_included errs ->
18201820
fprintf ppf "@[<v>Signature mismatch:@ %a@]" Includemod.report_error errs
1821+
| Cannot_eliminate_dependency mty ->
1822+
fprintf ppf
1823+
"@[This functor has type@ %a@ The parameter cannot be eliminated in the \
1824+
result type.@ Bind the argument to a module identifier.@]"
1825+
modtype mty
18211826
| Signature_expected -> fprintf ppf "This module type is not a signature"
18221827
| Structure_expected mty ->
18231828
fprintf ppf "@[This module is not a structure; it has type@ %a" modtype mty
@@ -1835,16 +1840,16 @@ let report_error ppf = function
18351840
"@[<v>@[This `with' constraint on %a makes the applicative functor @ \
18361841
type %s ill-typed in the constrained signature:@]@ %a@]"
18371842
longident lid (Path.name path) Includemod.report_error explanation
1838-
| With_cannot_remove_constrained_type ->
1839-
fprintf ppf
1840-
"@[<v>Destructive substitutions are not supported for constrained @ \
1841-
types (other than when replacing a type constructor with @ a type \
1842-
constructor with the same arguments).@]"
18431843
| With_changes_module_alias (lid, id, path) ->
18441844
fprintf ppf
18451845
"@[<v>@[This `with' constraint on %a changes %s, which is aliased @ in \
18461846
the constrained signature (as %s)@].@]"
18471847
longident lid (Path.name path) (Ident.name id)
1848+
| With_cannot_remove_constrained_type ->
1849+
fprintf ppf
1850+
"@[<v>Destructive substitutions are not supported for constrained @ \
1851+
types (other than when replacing a type constructor with @ a type \
1852+
constructor with the same arguments).@]"
18481853
| Repeated_name (kind, name, repeated_loc) ->
18491854
fprintf ppf
18501855
"@[Multiple definition of the %s name %s @ at @{<loc>%a@}@ @ Names must \
@@ -1873,11 +1878,6 @@ let report_error ppf = function
18731878
| Interface_not_compiled intf_name ->
18741879
fprintf ppf "@[Could not find the .cmi file for interface@ %a.@]"
18751880
Location.print_filename intf_name
1876-
| Cannot_eliminate_dependency mty ->
1877-
fprintf ppf
1878-
"@[This functor has type@ %a@ The parameter cannot be eliminated in the \
1879-
result type.@ Bind the argument to a module identifier.@]"
1880-
modtype mty
18811881
| Not_allowed_in_functor_body ->
18821882
fprintf ppf "@[This expression creates fresh types.@ %s@]"
18831883
"It is not allowed inside applicative functors."

0 commit comments

Comments
 (0)