Skip to content

Syntactic support for instance names as identifiers #1873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 251 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 249 commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
65d7cbd
Use `CU.Name.t` for name of .cmi; support import info for parameters
lukemaurer Aug 16, 2023
cf8f9e1
Missed a few changes
lukemaurer Aug 21, 2023
25b63ca
Refactor `Persistent_env` to separate imports from bound names
lukemaurer Aug 23, 2023
d0a1675
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Aug 23, 2023
5cde426
Add `-as-argument-for`
lukemaurer Aug 30, 2023
ef2c16b
Add checks for misuse of `-as-parameter`
lukemaurer Aug 30, 2023
546e73a
Raise error on combination of `-as-parameter` and `-for-pack`
lukemaurer Aug 30, 2023
7f03329
Add test for check for compiling `.ml` of parameter `.mli`
lukemaurer Aug 30, 2023
431d6bb
Add test of check for `-as-parameter` on implementation
lukemaurer Aug 30, 2023
37e88f3
Remove stray debug code
lukemaurer Aug 31, 2023
171ba39
Fix formatting
lukemaurer Aug 31, 2023
3d952f6
Implement `register_parameter_import` and `is_registered_parameter_im…
lukemaurer Aug 31, 2023
73835a0
Code review
lukemaurer Aug 31, 2023
f95b877
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Aug 31, 2023
e2c7976
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Aug 31, 2023
0c87e5c
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Aug 31, 2023
cd5ff12
Fix missing change to use of `Env.read_signature`
lukemaurer Sep 13, 2023
c4a43ca
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Sep 13, 2023
68dd87f
Pass shape into `Env` callback
lukemaurer Sep 13, 2023
bc78a1d
Improve API for reading signatures from files
lukemaurer Sep 13, 2023
3875b13
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Sep 13, 2023
0283acb
Forgot the code to check .mli files
lukemaurer Sep 20, 2023
61b5aee
Forgot the code to access double module blocks correctly
lukemaurer Sep 20, 2023
5d92b39
Add `-parameter` parameter
lukemaurer Sep 20, 2023
91ea4aa
Add missing objinfo code
lukemaurer Sep 26, 2023
c2cc72e
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Sep 26, 2023
7b6d875
Pull in `print_global_line` early
lukemaurer Sep 26, 2023
93b491f
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Sep 26, 2023
617dd89
Add to objinfo
lukemaurer Sep 26, 2023
ab62d1d
New library for computing instance names after substitution
lukemaurer Mar 8, 2023
2caadb2
Rename library to `Global`; defunctorize; move test
lukemaurer Mar 16, 2023
9124af4
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer Sep 27, 2023
4a5f03d
Hide records behind checked smart constructors
lukemaurer May 11, 2023
e901457
Have `subst` return original record if the result is equal
lukemaurer May 15, 2023
f8587a5
Fix bug introduced by last commit
lukemaurer May 15, 2023
67ad5fe
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer Sep 27, 2023
4710f66
Pull in changes from the 'instance-typing' branch
lukemaurer Aug 10, 2023
4b01ef5
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer Sep 27, 2023
db4fa04
Make `Global.Name.print` act like `CU.Name.print` in simple cases
lukemaurer Sep 20, 2023
3ad4ace
Merge branch 'instance-library' into global-name-is-module-id
lukemaurer Sep 27, 2023
0264bdd
Use `Global.Name.t` to stand for a module identifier
lukemaurer Sep 25, 2023
cd80dd5
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Sep 27, 2023
7a6f98e
Fix compilation following merge
lukemaurer Sep 26, 2023
ef9ee8c
objinfo: Include arguments in names of compilation units
lukemaurer Sep 26, 2023
28d352f
Pull in check for instance arguments on interface import
lukemaurer Sep 27, 2023
412f1cb
Syntactic support for instance names as identifiers
lukemaurer Sep 27, 2023
c24e14f
Code review
lukemaurer Sep 29, 2023
4336e64
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Sep 29, 2023
d530f6b
Add to .cmo format rather than only .cmx format
lukemaurer Oct 4, 2023
f403dd8
Fix comment
lukemaurer Oct 4, 2023
a529df1
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Oct 4, 2023
8440403
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Oct 4, 2023
243264c
Also change the new `cu_implements_param` field
lukemaurer Oct 4, 2023
c7f2a29
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Oct 4, 2023
8b52f69
Fix error message and re-enable test
lukemaurer Oct 19, 2023
c1ebcbe
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Oct 19, 2023
2dda1ca
Fix compilation following merge
lukemaurer Oct 19, 2023
a3b7a31
Update bootstrap compiler
lukemaurer Oct 19, 2023
fa251ce
Fix upstream build
lukemaurer Oct 19, 2023
6f86fb9
Disable test of error message
lukemaurer Oct 19, 2023
88b6185
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Oct 19, 2023
52ea8fd
Revert "Disable test of error message"
lukemaurer Oct 19, 2023
a9eea0b
Fix upstream build
lukemaurer Oct 19, 2023
4f01e24
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Oct 19, 2023
3c5b7b5
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Oct 19, 2023
d619a45
Fix conflicts
lukemaurer Oct 19, 2023
156fd09
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Oct 19, 2023
8b42e26
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Oct 19, 2023
b4ec625
Normalise test specification
lukemaurer Oct 20, 2023
591a4ec
Generate test specifications
lukemaurer Oct 10, 2023
268ebbd
Test native compilation
lukemaurer Oct 10, 2023
c15dcfb
Ability to add extra variables to actions in `gen_test`
lukemaurer Oct 11, 2023
0a8ee56
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Oct 20, 2023
a17d34c
Update test generation and add native tests
lukemaurer Oct 20, 2023
70b77ea
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Oct 20, 2023
dc1a3eb
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Oct 20, 2023
294ad42
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Nov 16, 2023
5518617
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Nov 16, 2023
77e4338
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Nov 17, 2023
23adeca
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Nov 17, 2023
9234fcd
Bootstrap
lukemaurer Nov 17, 2023
4b2f192
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Nov 17, 2023
025558c
Remove warning boilerplate from new files
lukemaurer Nov 17, 2023
4c0c8b6
Update `ocaml/.depend`
lukemaurer Nov 17, 2023
f494b9f
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Nov 17, 2023
3b8a7f5
Fix a bit of silly back-and-forth
lukemaurer Nov 17, 2023
daaf996
Update tests following rebase
lukemaurer Nov 17, 2023
987a2bd
Partially fix Closure
lukemaurer Nov 17, 2023
2c8ca86
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Nov 17, 2023
4dd61bb
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Dec 5, 2023
c67a202
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Dec 8, 2023
4322629
Use unnamed field instead of double module block
lukemaurer Dec 11, 2023
6d22bc4
Store argument block itself rather than coercion function
lukemaurer Dec 12, 2023
398cc90
Bring in squashed merge of 'as-parameter' branch
lukemaurer Dec 12, 2023
9db2c13
Merge branch 'unsquash/as-parameter' into cu-name-is-cmi
lukemaurer Dec 12, 2023
bf51bd8
Merge remote-tracking branch 'upstream/main' into cu-name-is-cmi
lukemaurer Dec 12, 2023
28654cc
Merge remote-tracking branch 'upstream/main' into unsquash/as-parameter
lukemaurer Dec 12, 2023
f1e32a9
Merge branch 'unsquash/as-parameter' into cu-name-is-cmi
lukemaurer Dec 12, 2023
7d7a241
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Dec 12, 2023
65e2a92
Fix build of upstream objinfo
lukemaurer Dec 12, 2023
dc7eeaf
Bootstrap
lukemaurer Dec 12, 2023
489b046
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Dec 13, 2023
fa9a22e
Fix upstream build
lukemaurer Dec 13, 2023
ff674e2
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Dec 13, 2023
4cfa38c
Update .depend
lukemaurer Dec 13, 2023
3cb1126
Code review
lukemaurer Dec 18, 2023
e05a7f5
Code review
lukemaurer Dec 19, 2023
b3be73d
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Dec 19, 2023
b07af9b
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Dec 19, 2023
a277c51
Bootstrap
lukemaurer Dec 19, 2023
73f2689
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Dec 19, 2023
e94a213
Fix compilation following merge
lukemaurer Dec 19, 2023
5de168d
Bootstrap
lukemaurer Dec 19, 2023
0372eae
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Dec 19, 2023
e8abb3a
Remove code gen changes from `-as-argument-for` branch
lukemaurer Dec 22, 2023
c816563
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Feb 5, 2024
1cee4f4
Remove code gen changes from 'parameter-parameter' branch
lukemaurer Feb 5, 2024
68e347c
Bootstrap
lukemaurer Feb 5, 2024
814a8a7
Remove more code gen code from 'parameter-parameter' branch
lukemaurer Feb 5, 2024
c36393a
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 5, 2024
95e7772
Generate stub variables for runtime parameters
lukemaurer Feb 7, 2024
abf0b5d
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 7, 2024
068617c
Merge tag 'global-name-is-module-id-with-code-gen' into instance-syntax
lukemaurer Feb 7, 2024
ab1ea2c
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Feb 7, 2024
2a33784
Fix formatting
lukemaurer Feb 8, 2024
f68d199
Define `Global.Name.t` in `jane_syntax.mli` to remove dependency
lukemaurer Feb 8, 2024
a6a06c5
Fix upstream build: don't let `Global` dep on `Jane_syntax` either
lukemaurer Feb 8, 2024
7d6f798
Rename `secondary_interface` to `argument_interface`
lukemaurer Feb 20, 2024
87ab117
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Feb 20, 2024
a903a9a
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 20, 2024
696b4c9
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Feb 20, 2024
c086a8a
Remove .cmx-related code gen code from 'parameter-parameter' branch
lukemaurer Feb 20, 2024
ee1958b
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 20, 2024
766cfa9
Fix compilation following merge
lukemaurer Feb 20, 2024
48c3576
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Feb 20, 2024
ccd7064
Overhaul `Import_info` implementation and new API
lukemaurer Apr 30, 2024
c6f988b
Code review
lukemaurer Apr 30, 2024
91c2329
Bootstrap
lukemaurer Apr 30, 2024
8a2b5c2
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Apr 30, 2024
a3641bb
Compilation fixes following merge
lukemaurer Apr 30, 2024
7e760a1
Copy changes from `asmlink.ml` to `asmlink.ml`
lukemaurer May 1, 2024
014a2d3
Rename a few things for consistency and update comments
lukemaurer May 1, 2024
66fb8b8
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer May 1, 2024
447c2dd
Merge remote-tracking branch 'upstream/main' into cu-name-is-cmi
lukemaurer May 1, 2024
f1be371
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer May 1, 2024
91b0725
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer May 1, 2024
d701be1
Code review
lukemaurer May 1, 2024
d4cacae
Re-check visibility on _either_ cache hit
lukemaurer May 1, 2024
efd3020
Merge remote-tracking branch 'upstream/main' into cu-name-is-cmi
lukemaurer May 9, 2024
2adb8bd
Rename a few things for code review
lukemaurer May 15, 2024
381a67c
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer May 15, 2024
4ad0aa3
Merge branch 'upstream/main' into layered-persistent_env, up to squas…
lukemaurer May 15, 2024
5af30a5
Bring in squashed merge of 'cu-name-is-cmi' branch
lukemaurer May 15, 2024
f255c62
Merge remote-tracking branch 'upstream/main' into layered-persistent_env
lukemaurer May 15, 2024
6c16e9d
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 15, 2024
9fcab53
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer May 15, 2024
288ed6c
Remove test spec generator
lukemaurer May 15, 2024
5f5a85b
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer May 22, 2024
1159e12
Remove now-unused functions from `Misc`
lukemaurer May 22, 2024
531c90c
Have `Global.subst` return whether the input changed
lukemaurer May 22, 2024
1e681ac
Bring in squashed merge of 'layered-persistent_env' branch
lukemaurer May 23, 2024
9dde77e
Rename `global.ml` to `global_module.ml` and move into `typing/`
lukemaurer May 28, 2024
6272975
Improve error messages
lukemaurer May 29, 2024
70a9aa2
Code review
lukemaurer May 29, 2024
2eb82e8
Translate test file ahead of rebase
lukemaurer May 30, 2024
59ea4f9
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
81e099e
Fix compilation following merge
lukemaurer May 30, 2024
ec20f9c
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
e6904d6
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
6733ace
Partially merge remote-tracking branch 'upstream/main' into as-argume…
lukemaurer May 30, 2024
84c9c49
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
7398e80
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
b87ccc0
Merge branch 'instance-library' into global-name-is-module-id
lukemaurer May 30, 2024
9595527
Restore `Misc.merge_iter` and `Misc.merge_map`
lukemaurer May 30, 2024
a87959b
Merge remote-tracking branch 'upstream/main' into as-argument-for
lukemaurer May 30, 2024
453d7a6
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
54637cf
Remove stale dynlink changes left over from 'instance-library' branch
lukemaurer May 30, 2024
4061e54
Add unsquashed 'instance-library' branch as parent
lukemaurer May 30, 2024
c6c696e
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
67e7bd9
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
dce211c
Fix compilation following merge
lukemaurer May 30, 2024
64802b5
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer May 30, 2024
156aa4d
More awful `dynlink_compilerlibs` fiddling
lukemaurer May 30, 2024
7b4bb09
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer May 30, 2024
5a8b458
Even more `dynlink` fiddling for my sins
lukemaurer Jun 4, 2024
a9eb21f
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Jun 4, 2024
33a0476
Put back inadvertently-removed argument label in `Typemod`
lukemaurer Jun 6, 2024
6e596bf
Don't register the argument type as a parameter import
lukemaurer Jun 6, 2024
051fb88
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Jun 6, 2024
91f658c
Remove concept of unexported parameters
lukemaurer Jun 6, 2024
0ebda3d
Make `param_imports` a `Param_set.t`
lukemaurer Jun 6, 2024
e554cb4
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jun 6, 2024
3feced2
Small bit of cleanup
lukemaurer Jun 6, 2024
cdc3017
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Jun 6, 2024
4fe7cf7
Remove test generation code (again)
lukemaurer Jun 12, 2024
dddbeaf
Add test for error on `-parameter A` when `A` is not a parameter
lukemaurer Jun 12, 2024
4e55d0d
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jun 12, 2024
420e422
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Jun 12, 2024
de086d2
Merge from 'upstream/main' up to squashed 'as-argument-for' branch
lukemaurer Jun 18, 2024
65376e1
Merge squashed 'as-argument-for' branch from 'upstream/main'
lukemaurer Jun 18, 2024
eb4f173
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jun 18, 2024
e38400f
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Jun 18, 2024
d04b0d6
Check for malformed instance names with nice error message
lukemaurer Jun 19, 2024
d13b95a
Test for check of repeated arg name
lukemaurer Jun 19, 2024
32ea6ef
Add test for positive case of subset rule
lukemaurer Jun 26, 2024
8466bfa
Bind parameterized modules locally
lukemaurer Jun 26, 2024
042b14d
Fix compilation
lukemaurer Jun 27, 2024
2f3ad28
Update tests to expect local binding of parameterized modules
lukemaurer Jun 27, 2024
79678ae
Update test output to account for missing flambda2 export information
lukemaurer Jun 27, 2024
44400e8
Skip output check for objinfo on .cmx
lukemaurer Jun 27, 2024
649b8e7
Always check for `-as-parameter` on implementation
lukemaurer Jun 28, 2024
1b350b9
Disallow combining `-as-parameter` and `-parameter`
lukemaurer Jun 28, 2024
08a831a
Code review: Improve error message for subset rule
lukemaurer Jul 3, 2024
e1c7627
Code review
lukemaurer Jul 3, 2024
298f477
More code review
lukemaurer Jul 3, 2024
949b7be
Code review: Use, explain "runtime parameters" terminology
lukemaurer Jul 3, 2024
de20fe3
Add a bit more explanation about runtime parameters
lukemaurer Jul 4, 2024
81c50a7
Properly stub out shapes of parameters and parameterised modules
lukemaurer Jul 4, 2024
114ff61
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jul 5, 2024
8a860d6
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Jul 5, 2024
e359add
Merge from 'upstream/main' up to squashed 'parameter-parameter' into …
lukemaurer Jul 5, 2024
5ae92d0
Merge squashed 'parameter-parameter' into global-name-is-module-id
lukemaurer Jul 5, 2024
6af59c1
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Jul 5, 2024
def8739
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Jul 5, 2024
5173c87
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Jul 8, 2024
ca4c418
Revert changes to `ocaml/.depend` relative to 'upstream/main'
lukemaurer Jul 9, 2024
e6e922c
Deal with stale upstream references to `Global`
lukemaurer Jul 9, 2024
0f76c03
Punt changes to `Shape`
lukemaurer Jul 9, 2024
227e212
Don't put line breaks in `name`s of idents
lukemaurer Jul 9, 2024
cf2a4a4
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Jul 18, 2024
e2b2da3
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Jul 18, 2024
e7cd6f8
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Aug 20, 2024
a843f8f
Introduce record type for instance arguments
lukemaurer Sep 23, 2024
084e460
Code review
lukemaurer Sep 23, 2024
2cb6c92
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Sep 23, 2024
4753683
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Sep 23, 2024
ea3d62e
Merge tag '5.1.1minus-24' into global-name-is-module-id
lukemaurer Sep 24, 2024
1625c02
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Sep 25, 2024
86eac6d
Remove accidental copy of `Makefile.compilerlibs`
lukemaurer Sep 25, 2024
e143e8b
Reluctantly fix failure of egregious test
lukemaurer Sep 26, 2024
70ea5f6
Code review
lukemaurer Sep 26, 2024
3d0b5d1
One more change I left out of code review
lukemaurer Sep 26, 2024
ca2da75
Merge branch 'global-name-is-module-id' into instance-syntax
lukemaurer Sep 27, 2024
4303bb2
Fix compilation following merge
lukemaurer Sep 27, 2024
de4a3f4
Merge 'upstream/main' up to squashed 'global-name-is-module-id' into …
lukemaurer Sep 27, 2024
1946573
Pull squash of 'global-name-is-module-id' into instance-syntax
lukemaurer Sep 27, 2024
dd19fcd
Reintroduce whitespace errors that ocamlformat wants
lukemaurer Sep 27, 2024
60fa615
Update expect tests following merge
lukemaurer Sep 27, 2024
41cc13a
Code review
lukemaurer Sep 30, 2024
b2b3dbc
Clarify stub code
lukemaurer Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ocaml/driver/compile_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let emit_signature info alerts tsg =
else begin
let cmi_arg_for =
match !Clflags.as_argument_for with
| Some arg_type -> Some (Global_module.Name.create arg_type [])
| Some arg_type -> Some (Global_module.Name.create_exn arg_type [])
| None -> None
in
Normal { cmi_impl = info.module_name; cmi_arg_for }
Expand Down
19 changes: 18 additions & 1 deletion ocaml/parsing/ast_iterator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type iterator = {
module_declaration: iterator -> module_declaration -> unit;
module_substitution: iterator -> module_substitution -> unit;
module_expr: iterator -> module_expr -> unit;
module_expr_jane_syntax: iterator -> Jane_syntax.Module_expr.t -> unit;
module_type: iterator -> module_type -> unit;
module_type_declaration: iterator -> module_type_declaration -> unit;
module_type_jane_syntax: iterator -> Jane_syntax.Module_type.t -> unit;
Expand Down Expand Up @@ -403,9 +404,24 @@ end
module M = struct
(* Value expressions for the module language *)

let iter sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} =
module I = Jane_syntax.Instances

let iter_instance _sub : I.instance -> _ = function
| _ -> () (* Currently treating these as atomic? *)

let iter_instance_expr sub : I.module_expr -> _ = function
| Imod_instance i -> iter_instance sub i

let iter_ext sub : Jane_syntax.Module_expr.t -> _ = function
| Emod_instance i -> iter_instance_expr sub i

let iter sub
({pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} as expr) =
sub.location sub loc;
sub.attributes sub attrs;
match Jane_syntax.Module_expr.of_ast expr with
| Some ext -> sub.module_expr_jane_syntax sub ext
| None ->
match desc with
| Pmod_ident x -> iter_loc sub x
| Pmod_structure str -> sub.structure sub str
Expand Down Expand Up @@ -760,6 +776,7 @@ let default_iterator =
structure_item = M.iter_structure_item;
structure_item_jane_syntax = M.iter_structure_item_jst;
module_expr = M.iter;
module_expr_jane_syntax = M.iter_ext;
signature = (fun this l -> List.iter (this.signature_item this) l);
signature_item = MT.iter_signature_item;
signature_item_jane_syntax = MT.iter_signature_item_jst;
Expand Down
1 change: 1 addition & 0 deletions ocaml/parsing/ast_iterator.mli
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type iterator = {
module_declaration: iterator -> module_declaration -> unit;
module_substitution: iterator -> module_substitution -> unit;
module_expr: iterator -> module_expr -> unit;
module_expr_jane_syntax: iterator -> Jane_syntax.Module_expr.t -> unit;
module_type: iterator -> module_type -> unit;
module_type_declaration: iterator -> module_type_declaration -> unit;
module_type_jane_syntax: iterator -> Jane_syntax.Module_type.t -> unit;
Expand Down
23 changes: 22 additions & 1 deletion ocaml/parsing/ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ type mapper = {
Jane_syntax.Extension_constructor.t -> Jane_syntax.Extension_constructor.t;
module_type_jane_syntax: mapper
-> Jane_syntax.Module_type.t -> Jane_syntax.Module_type.t;
module_expr_jane_syntax: mapper
-> Jane_syntax.Module_expr.t -> Jane_syntax.Module_expr.t;
pat_jane_syntax: mapper -> Jane_syntax.Pattern.t -> Jane_syntax.Pattern.t;
signature_item_jane_syntax: mapper ->
Jane_syntax.Signature_item.t -> Jane_syntax.Signature_item.t;
Expand Down Expand Up @@ -479,12 +481,30 @@ end


module M = struct
module I = Jane_syntax.Instances

(* Value expressions for the module language *)
let map_instance _sub : I.instance -> I.instance = function
| i -> i (* Currently treating these as atomic? *)

let map_instance_expr sub : I.module_expr -> I.module_expr = function
| Imod_instance i -> Imod_instance (map_instance sub i)

let map_ext sub : Jane_syntax.Module_expr.t -> Jane_syntax.Module_expr.t =
function
| Emod_instance i -> Emod_instance (map_instance_expr sub i)

let map sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} =
let map sub
({pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} as mexpr) =
let open Mod in
let loc = sub.location sub loc in
let attrs = sub.attributes sub attrs in
match Jane_syntax.Module_expr.of_ast mexpr with
| Some ext -> begin
match sub.module_expr_jane_syntax sub ext with
| Emod_instance i -> Jane_syntax.Instances.module_expr_of ~loc i
end
| None ->
match desc with
| Pmod_ident x -> ident ~loc ~attrs (map_loc sub x)
| Pmod_structure str -> structure ~loc ~attrs (sub.structure sub str)
Expand Down Expand Up @@ -887,6 +907,7 @@ let default_mapper =
structure = (fun this l -> List.map (this.structure_item this) l);
structure_item = M.map_structure_item;
module_expr = M.map;
module_expr_jane_syntax = M.map_ext;
signature = (fun this l -> List.map (this.signature_item this) l);
signature_item = MT.map_signature_item;
module_type = MT.map;
Expand Down
2 changes: 2 additions & 0 deletions ocaml/parsing/ast_mapper.mli
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ type mapper = {
Jane_syntax.Extension_constructor.t -> Jane_syntax.Extension_constructor.t;
module_type_jane_syntax: mapper ->
Jane_syntax.Module_type.t -> Jane_syntax.Module_type.t;
module_expr_jane_syntax: mapper ->
Jane_syntax.Module_expr.t -> Jane_syntax.Module_expr.t;
pat_jane_syntax: mapper -> Jane_syntax.Pattern.t -> Jane_syntax.Pattern.t;
signature_item_jane_syntax: mapper ->
Jane_syntax.Signature_item.t -> Jane_syntax.Signature_item.t;
Expand Down
72 changes: 72 additions & 0 deletions ocaml/parsing/jane_syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,66 @@ module Layouts = struct
| _ -> failwith "Malformed [kind_abbrev] in structure"
end

module Instances = struct
type instance =
{ head : string;
args : (instance * instance) list
}

type module_expr = Imod_instance of instance

let feature : Feature.t = Language_extension Instances

let rec module_expr_of_instance ~loc { head; args } =
let head = Ast_helper.Mod.ident ~loc { txt = Lident head; loc } in
match args with
| [] -> head
| _ ->
let args =
List.concat_map
(fun (param, value) ->
let param = module_expr_of_instance ~loc param in
let value = module_expr_of_instance ~loc value in
[param; value])
args
in
List.fold_left (Ast_helper.Mod.apply ~loc) head args

let module_expr_of ~loc = function
| Imod_instance instance ->
Module_expr.make_entire_jane_syntax ~loc feature (fun () ->
module_expr_of_instance ~loc instance)

let head_of_ident (lid : Longident.t Location.loc) =
match lid with
| { txt = Lident s; loc = _ } -> s
| _ -> failwith "Malformed instance identifier"

let gather_args mexpr =
let rec loop mexpr rev_acc =
match mexpr.pmod_desc with
| Pmod_apply (f, v) -> (
match f.pmod_desc with
| Pmod_apply (f, n) -> loop f ((n, v) :: rev_acc)
| _ -> failwith "Malformed instance identifier")
| head -> head, List.rev rev_acc
in
loop mexpr []

let rec instance_of_module_expr mexpr =
match gather_args mexpr with
| Pmod_ident i, args ->
let head = head_of_ident i in
let args = List.map instances_of_arg_pair args in
{ head; args }
| _ -> failwith "Malformed instance identifier"

and instances_of_arg_pair (n, v) =
instance_of_module_expr n, instance_of_module_expr v

let of_module_expr mexpr = Imod_instance (instance_of_module_expr mexpr)
end

(******************************************************************************)
(** The interface to our novel syntax, which we export *)

Expand Down Expand Up @@ -1391,6 +1451,18 @@ module Module_type = struct
{ mty with pmty_attributes = mty.pmty_attributes @ attrs }
end

module Module_expr = struct
type t = Emod_instance of Instances.module_expr

let of_ast_internal (feat : Feature.t) sigi =
match feat with
| Language_extension Instances ->
Some (Emod_instance (Instances.of_module_expr sigi))
| _ -> None

let of_ast = Module_expr.make_of_ast ~of_ast_internal
end

module Signature_item = struct
type t = Jsig_layout of Layouts.signature_item

Expand Down
20 changes: 20 additions & 0 deletions ocaml/parsing/jane_syntax.mli
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,19 @@ module Layouts : sig
(Jkind.annotation * Parsetree.attributes) option
end

module Instances : sig
(** The name of an instance module. Gets converted to [Global.Name.t] in the
flambda-backend compiler. *)
type instance =
{ head : string;
args : (instance * instance) list
}

type module_expr = Imod_instance of instance

val module_expr_of : loc:Location.t -> module_expr -> Parsetree.module_expr
end

(******************************************)
(* General facility, which we export *)

Expand Down Expand Up @@ -452,3 +465,10 @@ module Extension_constructor : sig
t ->
Parsetree.extension_constructor
end

(** Novel syntax in module expressions *)
module Module_expr : sig
type t = Emod_instance of Instances.module_expr

include AST with type t := t and type ast := Parsetree.module_expr
end
16 changes: 16 additions & 0 deletions ocaml/parsing/jane_syntax_parsing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,21 @@ module Module_type0 = Make_with_attribute (struct
let with_attributes mty pmty_attributes = { mty with pmty_attributes }
end)

(** Module expressions; embedded using an attribute on the module expression. *)
module Module_expr0 = Make_with_attribute (struct
type ast = module_expr

let plural = "module expressions"

let location mexpr = mexpr.pmod_loc

let with_location mexpr l = { mexpr with pmod_loc = l }

let attributes mexpr = mexpr.pmod_attributes

let with_attributes mexpr pmod_attributes = { mexpr with pmod_attributes }
end)

(** Extension constructors; embedded using an attribute. *)
module Extension_constructor0 = Make_with_attribute (struct
type ast = extension_constructor
Expand Down Expand Up @@ -849,6 +864,7 @@ let make_jane_syntax_attribute feature trailing_components payload =
module Expression = Make_ast (Expression0)
module Pattern = Make_ast (Pattern0)
module Module_type = Make_ast (Module_type0)
module Module_expr = Make_ast (Module_expr0)
module Signature_item = Make_ast (Signature_item0)
module Structure_item = Make_ast (Structure_item0)
module Core_type = Make_ast (Core_type0)
Expand Down
2 changes: 2 additions & 0 deletions ocaml/parsing/jane_syntax_parsing.mli
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ module Pattern : AST with type ast = Parsetree.pattern

module Module_type : AST with type ast = Parsetree.module_type

module Module_expr : AST with type ast = Parsetree.module_expr

module Signature_item : AST with type ast = Parsetree.signature_item

module Structure_item : AST with type ast = Parsetree.structure_item
Expand Down
21 changes: 20 additions & 1 deletion ocaml/parsing/pprintast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,9 @@ and module_expr ctxt f x =
if x.pmod_attributes <> [] then
pp f "((%a)%a)" (module_expr ctxt) {x with pmod_attributes=[]}
(attributes ctxt) x.pmod_attributes
else match x.pmod_desc with
else match Jane_syntax.Module_expr.of_ast x with
| Some ext -> extension_module_expr ctxt f ext
| None -> match x.pmod_desc with
| Pmod_structure (s) ->
pp f "@[<hv2>struct@;@[<0>%a@]@;<1 -2>end@]"
(list (structure_item ctxt) ~sep:"@\n") s;
Expand Down Expand Up @@ -2336,6 +2338,23 @@ and labeled_tuple_expr ctxt f ~unboxed x =
pp f "@[<hov2>%s(%a)@]" (if unboxed then "#" else "")
(list (tuple_component ctxt) ~sep:",@;") x

and extension_module_expr ctxt f (x : Jane_syntax.Module_expr.t) =
match x with
| Emod_instance i -> instance_module_expr ctxt f i

and instance_module_expr ctxt f (x : Jane_syntax.Instances.module_expr) =
match x with
| Imod_instance i -> instance ctxt f i

and instance ctxt f (x : Jane_syntax.Instances.instance) =
match x with
| { head; args = [] } -> pp f "%s" head
| { head; args } ->
pp f "@[<2>%s %a@]" head (list (instance_arg ctxt)) args

and instance_arg ctxt f (param, value) =
pp f "@[<1>(%a)@;(%a)@]" (instance ctxt) param (instance ctxt) value

(******************************************************************************)
(* All exported functions must be defined or redefined below here and wrapped in
[export_printer] in order to ensure they are invariant with respecto which
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Monoid_utils_of_list_monoid =
Monoid_utils(Monoid)(List_monoid)(Monoid)(List_monoid) [@jane.non_erasable.instances]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
File "bad_instance_repeated_arg_name.ml", line 2, characters 2-56:
2 | Monoid_utils(Monoid)(List_monoid)(Monoid)(List_monoid) [@jane.non_erasable.instances]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This instance has multiple arguments with the name "Monoid".
19 changes: 19 additions & 0 deletions ocaml/testsuite/tests/templates/basic/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
readonly_files = "\
bad_arg_impl.ml bad_arg_impl.reference \
bad_arg_intf.mli bad_arg_intf.reference \
bad_instance_repeated_arg_name.ml bad_instance_repeated_arg_name.reference \
bad_param_param.mli bad_param_param.reference \
bad_ref_direct.ml bad_ref_direct.reference \
bad_ref_indirect.reference \
Expand Down Expand Up @@ -128,6 +129,15 @@

reference = "monoid_utils_as_program.reference";
check-program-output;
}{
flags = "-parameter Semigroup";
module = "bad_instance_repeated_arg_name.ml";
compiler_output = "bad_instance_repeated_arg_name.output";
ocamlc_byte_exit_status = "2";
ocamlc.byte;

compiler_reference = "bad_instance_repeated_arg_name.reference";
check-ocamlc.byte-output;
}
}
}{
Expand Down Expand Up @@ -247,6 +257,15 @@

reference = "monoid_utils_as_program.reference";
check-program-output;
}{
flags = "-parameter Semigroup";
module = "bad_instance_repeated_arg_name.ml";
compiler_output = "bad_instance_repeated_arg_name.output";
ocamlopt_byte_exit_status = "2";
ocamlopt.byte;

compiler_reference = "bad_instance_repeated_arg_name.reference";
check-ocamlopt.byte-output;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ val g : unit -> int = <fun>
Exception: Not_found.
Raised at Stdlib__Map.Make.find in file "map.ml", line 146, characters 10-25
Called from Env.find_type_data in file "ocaml/typing/env.ml", line 1275, characters 8-48
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 309, characters 6-21
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 307, characters 6-21
Called from Env.IdTbl.find_same_without_locks in file "ocaml/typing/env.ml", line 428, characters 10-40
Re-raised at Stdlib__Map.Make.find in file "map.ml", line 146, characters 10-25
Called from Env.find_type_data in file "ocaml/typing/env.ml", line 1275, characters 8-48
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 309, characters 6-21
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 307, characters 6-21
Called from Env.IdTbl.find_same_without_locks in file "ocaml/typing/env.ml", line 428, characters 10-40
Re-raised at Stdlib__Map.Make.find in file "map.ml", line 146, characters 10-25
Called from Env.find_type_data in file "ocaml/typing/env.ml", line 1275, characters 8-48
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 309, characters 6-21
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 307, characters 6-21
Called from Env.IdTbl.find_same_without_locks in file "ocaml/typing/env.ml", line 428, characters 10-40
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 309, characters 6-21
Re-raised at Ident.find_same in file "ocaml/typing/ident.ml", line 307, characters 6-21
Called from Translmod.toplevel_name in file "ocaml/lambda/translmod.ml", line 1599, characters 6-40
Re-raised at Stdlib__Hashtbl.find in file "hashtbl.ml", line 547, characters 13-28
Called from Simplif.simplify_lets.simplif in file "ocaml/lambda/simplif.ml", line 571, characters 8-28
Expand Down
Loading