summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authoroctachron <octa@polychoron.fr>2021-05-05 14:25:39 +0200
committeroctachron <octa@polychoron.fr>2021-05-06 11:50:31 +0200
commitc52f1d06c2ea812ad5a87cc3aea1c0abfb15b44a (patch)
treead319daeb0cf139c0e409bb4220024954d091e2b /testsuite
parent9ce0b9b36493340a6ae06991a1906b6ce0abb4fe (diff)
downloadocaml-c52f1d06c2ea812ad5a87cc3aea1c0abfb15b44a.tar.gz
with constraint: ignore ghost components
"With" constraint should not be able to manipulate independently ghost signature components. For instance, in module type s = sig class c: object end end with type c := < > the compiler should fail with a missing component item rather than silently remove the ghost type of the class c.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/typing-modules/with_ghosts.ml31
1 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/typing-modules/with_ghosts.ml b/testsuite/tests/typing-modules/with_ghosts.ml
new file mode 100644
index 0000000000..bd500139ff
--- /dev/null
+++ b/testsuite/tests/typing-modules/with_ghosts.ml
@@ -0,0 +1,31 @@
+(* TEST
+ * expect
+*)
+
+(**
+ Check the behavior of with constraints with respect to
+ ghost type items introduced for class and class types
+ *)
+
+module type s = sig
+ class type c = object method m: int end
+end with type c := <m : int >
+[%%expect {|
+Lines 6-8, characters 16-29:
+6 | ................sig
+7 | class type c = object method m: int end
+8 | end with type c := <m : int >
+Error: The signature constrained by `with' has no component named c
+|}]
+
+
+module type s = sig
+ class type ct = object method m: int end
+end with type ct := <m : int >
+[%%expect {|
+Lines 1-3, characters 16-30:
+1 | ................sig
+2 | class type ct = object method m: int end
+3 | end with type ct := <m : int >
+Error: The signature constrained by `with' has no component named ct
+|}]