diff --git a/changes/private-in-printed-types.fix.md b/changes/private-in-printed-types.fix.md new file mode 100644 index 0000000000..a843b18f2f --- /dev/null +++ b/changes/private-in-printed-types.fix.md @@ -0,0 +1 @@ +- Print `private` for abbreviations and variants in type mismatch errors and other printed type declarations. diff --git a/compiler/syntax/src/res_outcome_printer.ml b/compiler/syntax/src/res_outcome_printer.ml index 7ad5747e51..54a560a445 100644 --- a/compiler/syntax/src/res_outcome_printer.ml +++ b/compiler/syntax/src/res_outcome_printer.ml @@ -694,7 +694,16 @@ let rec print_out_sig_item_doc ?(print_name_as_is = false) private_doc; print_record_declaration_doc ~inline:false record; ] - | typ -> Doc.concat [Doc.text " = "; print_out_type_doc typ] + | Otyp_manifest (manifest, typ) -> + Doc.concat + [ + Doc.text " = "; + print_out_type_doc manifest; + Doc.text " = "; + private_doc; + print_out_type_doc typ; + ] + | typ -> Doc.concat [Doc.text " = "; private_doc; print_out_type_doc typ] in let constraints = match out_type_decl.otype_cstrs with diff --git a/tests/build_tests/super_errors/expected/object_private_row_grants_set.res.expected b/tests/build_tests/super_errors/expected/object_private_row_grants_set.res.expected index 1d1d476ef9..7b18c2610c 100644 --- a/tests/build_tests/super_errors/expected/object_private_row_grants_set.res.expected +++ b/tests/build_tests/super_errors/expected/object_private_row_grants_set.res.expected @@ -12,16 +12,16 @@ Signature mismatch: Modules do not match: { - type t = {.."x": int} + type t = private {.."x": int} } is not included in { - type t = {..@set "x": int} + type t = private {..@set "x": int} } Type declarations do not match: - type t = {.."x": int} + type t = private {.."x": int} is not included in - type t = {..@set "x": int} + type t = private {..@set "x": int} /.../fixtures/object_private_row_grants_set.res:6:3-36: Expected declaration /.../fixtures/object_private_row_grants_set.res:8:3-31: diff --git a/tests/build_tests/super_errors_multi/expected/Cross_private_abbreviation_mismatch.expected b/tests/build_tests/super_errors_multi/expected/Cross_private_abbreviation_mismatch.expected new file mode 100644 index 0000000000..71730354d1 --- /dev/null +++ b/tests/build_tests/super_errors_multi/expected/Cross_private_abbreviation_mismatch.expected @@ -0,0 +1,20 @@ +===== Priv.res ===== + + We've found a bug for you! + /.../fixtures/Cross_private_abbreviation_mismatch/Priv.res:3:1-10 + + 1 │ type a + 2 │ type b + 3 │ type t = b + 4 │ + + The implementation /.../fixtures/Cross_private_abbreviation_mismatch/Priv.res + does not match the interface /.../fixtures/Cross_private_abbreviation_mismatch/priv.cmi: + Type declarations do not match: + type t = b + is not included in + type t = private a + /.../fixtures/Cross_private_abbreviation_mismatch/Priv.resi:2:1-18: + Expected declaration + /.../fixtures/Cross_private_abbreviation_mismatch/Priv.res:3:1-10: + Actual declaration \ No newline at end of file diff --git a/tests/build_tests/super_errors_multi/expected/Cross_private_variant_manifest_mismatch.expected b/tests/build_tests/super_errors_multi/expected/Cross_private_variant_manifest_mismatch.expected new file mode 100644 index 0000000000..2e76d32d92 --- /dev/null +++ b/tests/build_tests/super_errors_multi/expected/Cross_private_variant_manifest_mismatch.expected @@ -0,0 +1,19 @@ +===== Priv.res ===== + + We've found a bug for you! + /.../fixtures/Cross_private_variant_manifest_mismatch/Priv.res:2:1-14 + + 1 │ type v = A | B + 2 │ type w = A | B + 3 │ + + The implementation /.../fixtures/Cross_private_variant_manifest_mismatch/Priv.res + does not match the interface /.../fixtures/Cross_private_variant_manifest_mismatch/priv.cmi: + Type declarations do not match: + type w = A | B + is not included in + type w = v = private A | B + /.../fixtures/Cross_private_variant_manifest_mismatch/Priv.resi:2:1-26: + Expected declaration + /.../fixtures/Cross_private_variant_manifest_mismatch/Priv.res:2:1-14: + Actual declaration \ No newline at end of file diff --git a/tests/build_tests/super_errors_multi/expected/Iface_privacy_mismatch.expected b/tests/build_tests/super_errors_multi/expected/Iface_privacy_mismatch.expected index 621a81f6ec..c8b4726a2b 100644 --- a/tests/build_tests/super_errors_multi/expected/Iface_privacy_mismatch.expected +++ b/tests/build_tests/super_errors_multi/expected/Iface_privacy_mismatch.expected @@ -9,7 +9,7 @@ The implementation /.../fixtures/Iface_privacy_mismatch/Foo.res does not match the interface /.../fixtures/Iface_privacy_mismatch/foo.cmi: Type declarations do not match: - type t = int + type t = private int is not included in type t = int /.../fixtures/Iface_privacy_mismatch/Foo.resi:1:1-12: diff --git a/tests/build_tests/super_errors_multi/fixtures/Cross_private_abbreviation_mismatch/Priv.res b/tests/build_tests/super_errors_multi/fixtures/Cross_private_abbreviation_mismatch/Priv.res new file mode 100644 index 0000000000..bae91f6e9f --- /dev/null +++ b/tests/build_tests/super_errors_multi/fixtures/Cross_private_abbreviation_mismatch/Priv.res @@ -0,0 +1,3 @@ +type a +type b +type t = b diff --git a/tests/build_tests/super_errors_multi/fixtures/Cross_private_abbreviation_mismatch/Priv.resi b/tests/build_tests/super_errors_multi/fixtures/Cross_private_abbreviation_mismatch/Priv.resi new file mode 100644 index 0000000000..01325fdbda --- /dev/null +++ b/tests/build_tests/super_errors_multi/fixtures/Cross_private_abbreviation_mismatch/Priv.resi @@ -0,0 +1,2 @@ +type a +type t = private a diff --git a/tests/build_tests/super_errors_multi/fixtures/Cross_private_variant_manifest_mismatch/Priv.res b/tests/build_tests/super_errors_multi/fixtures/Cross_private_variant_manifest_mismatch/Priv.res new file mode 100644 index 0000000000..c148fc66c1 --- /dev/null +++ b/tests/build_tests/super_errors_multi/fixtures/Cross_private_variant_manifest_mismatch/Priv.res @@ -0,0 +1,2 @@ +type v = A | B +type w = A | B diff --git a/tests/build_tests/super_errors_multi/fixtures/Cross_private_variant_manifest_mismatch/Priv.resi b/tests/build_tests/super_errors_multi/fixtures/Cross_private_variant_manifest_mismatch/Priv.resi new file mode 100644 index 0000000000..4e9712b903 --- /dev/null +++ b/tests/build_tests/super_errors_multi/fixtures/Cross_private_variant_manifest_mismatch/Priv.resi @@ -0,0 +1,2 @@ +type v = A | B +type w = v = private A | B