diff options
author | François Pottier <francois.pottier@inria.fr> | 2018-10-03 08:18:20 +0200 |
---|---|---|
committer | François Pottier <francois.pottier@inria.fr> | 2018-11-20 11:52:47 +0100 |
commit | 0d328a7c839be442d8fe8b70eabf86cea4f91802 (patch) | |
tree | 11482264e6cfb4d0f5cf212c2f821118de8c6d58 /testsuite | |
parent | a8edab585795919f8c2ba181c3f4cf3ea8e5d704 (diff) | |
download | ocaml-0d328a7c839be442d8fe8b70eabf86cea4f91802.tar.gz |
Changed the definition of `formal_class_parameters` to allow the use
of an anonymous type variable as a formal parameter to a class.
This enlarges the language, and can be considered a bug fix, as
the printer (`ocamlc -i`) could actually produce this form.
Added a test case.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/parsing/anonymous_class_parameter.compilers.reference | 1 | ||||
-rw-r--r-- | testsuite/tests/parsing/anonymous_class_parameter.ml | 15 | ||||
-rw-r--r-- | testsuite/tests/parsing/ocamltests | 1 |
3 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/parsing/anonymous_class_parameter.compilers.reference b/testsuite/tests/parsing/anonymous_class_parameter.compilers.reference new file mode 100644 index 0000000000..bc33550147 --- /dev/null +++ b/testsuite/tests/parsing/anonymous_class_parameter.compilers.reference @@ -0,0 +1 @@ +class ['a, _] foo : object method bar : 'a -> 'a end diff --git a/testsuite/tests/parsing/anonymous_class_parameter.ml b/testsuite/tests/parsing/anonymous_class_parameter.ml new file mode 100644 index 0000000000..bbecc1272b --- /dev/null +++ b/testsuite/tests/parsing/anonymous_class_parameter.ml @@ -0,0 +1,15 @@ +(* TEST + flags = "-i" + * setup-ocamlc.byte-build-env + ** ocamlc.byte + *** check-ocamlc.byte-output +*) + +(* This test is valid OCaml code. + It uses an anonymous type variable as a formal parameter in a class + declaration. This used to be rejected by the parser, even though the + printer (ocamlc -i) could in fact produce it. *) + +class ['a, _] foo = object + method bar: 'a -> 'a = fun x -> x +end diff --git a/testsuite/tests/parsing/ocamltests b/testsuite/tests/parsing/ocamltests index 8585bb97c5..42e3fbabfd 100644 --- a/testsuite/tests/parsing/ocamltests +++ b/testsuite/tests/parsing/ocamltests @@ -1,3 +1,4 @@ +anonymous_class_parameter.ml arrow_ambiguity.ml attributes.ml broken_invariants.ml |