forked from ocaml-flambda/flambda-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
-as-parameter
option (ocaml-flambda#1751)
* Add `-as-parameter` option This allows compiling an .mli as a _parameter module_ rather than a normal compilation unit. A parameter module defines a module _type_ rather than a module, so it cannot be referred to directly from another module. A forthcoming PR will add the `-parameter P` option which adds the parameter module `P` as a parameter to the current module, which then allows references to `P` in the module. Further PRs will deal with how to actually use a module that takes parameters. For the moment, `-parameter` is unimplemented, so any reference to a parameter module is an error. * Add checks for misuse of `-as-parameter` * Raise error on combination of `-as-parameter` and `-for-pack` * Add test for check for compiling `.ml` of parameter `.mli` I've disabled the check on the output, since currently we get the wrong error message (and the one we get is confusing). This will be much easier to fix when PR ocaml-flambda#1764 is fixed to avoid unhelpful checks on `.mli` files that are loaded directly rather than as part of name resolution. * Add test of check for `-as-parameter` on implementation * Implement `register_parameter_import` and `is_registered_parameter_import` * Code review * Code review * Fix error message and re-enable test
- Loading branch information
1 parent
c30715f
commit 22b6dd4
Showing
30 changed files
with
278 additions
and
33 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
ocaml/testsuite/tests/templates/basic/bad_impl_as_param.ml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(* TEST | ||
readonly_files = "bad_impl_as_param.reference" | ||
* setup-ocamlc.byte-build-env | ||
** ocamlc.byte | ||
flags = "-as-parameter" | ||
modules = "bad_impl_as_param.ml" | ||
ocamlc_byte_exit_status = "2" | ||
compiler_output = "bad_impl_as_param.output" | ||
*** check-ocamlc.byte-output | ||
compiler_reference = "bad_impl_as_param.reference" *) |
2 changes: 2 additions & 0 deletions
2
ocaml/testsuite/tests/templates/basic/bad_impl_as_param.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
File "bad_impl_as_param.ml", line 1: | ||
Error: Cannot compile an implementation with -as-parameter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(* TEST | ||
readonly_files = "bad_param_impl.mli bad_param_impl.reference" | ||
* setup-ocamlc.byte-build-env | ||
** ocamlc.byte | ||
flags = "-as-parameter" | ||
module = "bad_param_impl.mli" | ||
*** ocamlc.byte | ||
flags = "" | ||
module = "bad_param_impl.ml" | ||
ocamlc_byte_exit_status = "2" | ||
compiler_output = "bad_param_impl.output" | ||
**** check-ocamlc.byte-output | ||
compiler_reference = "bad_param_impl.reference" | ||
*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(* To be compiled with [-as-parameter] *) |
3 changes: 3 additions & 0 deletions
3
ocaml/testsuite/tests/templates/basic/bad_param_impl.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
File "bad_param_impl.ml", line 1: | ||
Error: The interface for Bad_param_impl was compiled with -as-parameter. | ||
It cannot be implemented directly. |
13 changes: 13 additions & 0 deletions
13
ocaml/testsuite/tests/templates/basic/bad_param_packed.mli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(* TEST | ||
readonly_files = "bad_param_packed.reference" | ||
* setup-ocamlc.byte-build-env | ||
** ocamlc.byte | ||
flags = "-as-parameter -for-pack Pack" | ||
module = "bad_param_packed.mli" | ||
compiler_output = "bad_param_packed.output" | ||
ocamlc_byte_exit_status = "2" | ||
*** check-ocamlc.byte-output | ||
compiler_reference = "bad_param_packed.reference" | ||
*) |
2 changes: 2 additions & 0 deletions
2
ocaml/testsuite/tests/templates/basic/bad_param_packed.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
File "_none_", line 1: | ||
Error: Cannot compile a parameter with -for-pack. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(* [Monoid] is not a parameter *) | ||
|
||
let empty = Monoid.id |
3 changes: 3 additions & 0 deletions
3
ocaml/testsuite/tests/templates/basic/bad_ref_direct.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
File "bad_ref_direct.ml", line 1: | ||
Error: The file monoid.cmi contains the interface of a parameter. | ||
Monoid is not declared as a parameter for the current unit (-parameter Monoid). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type t | ||
|
||
val empty : t | ||
val append : t -> t -> t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(* TEST | ||
readonly_files = "\ | ||
bad_ref_direct.ml bad_ref_direct.reference \ | ||
monoid.mli \ | ||
" | ||
* setup-ocamlc.byte-build-env | ||
** ocamlc.byte | ||
flags = "-as-parameter" | ||
module = "monoid.mli" | ||
*** ocamlc.byte | ||
module = "bad_ref_direct.ml" | ||
compiler_output = "bad_ref_direct.output" | ||
ocamlc_byte_exit_status = "2" | ||
**** check-ocamlc.byte-output | ||
compiler_reference = "bad_ref_direct.reference" | ||
*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.