Skip to content

Commit

Permalink
Merge branch 'main' into spotandjake-completion
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake authored Aug 20, 2023
2 parents f624290 + 97c00e1 commit b50da63
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 31 deletions.
4 changes: 3 additions & 1 deletion compiler/src/middle_end/linearize.re
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ let lookup_symbol = (~env, ~allocation_type, ~repr, path) => {
item =>
switch (item) {
| TSigValue(_, {val_fullpath: PIdent(id)}) =>
Hashtbl.add(mod_map, Ident.name(id), id)
let name = Ident.name(id);
Hashtbl.add(mod_map, name, id);
Path_tbl.add(include_map, PExternal(mod_, name), id);
| TSigValue(_) =>
failwith("Impossible: internal value with external path")
| TSigType(_, _, _)
Expand Down
10 changes: 1 addition & 9 deletions compiler/src/typed/typemod.re
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,7 @@ let rec type_module = (~toplevel=false, anchor, env, statements) => {
{tex_id: id, tex_path: path, tex_loc: val_loc},
...provided_values^,
];
// If this module was imported, we'll set the internal path
// to be picked up later to be re-exported. Otherwise, these
// values originated in this module.
let val_internalpath =
switch (mod_decl.md_filepath) {
| Some(_) => path
| _ => val_internalpath
};
TSigValue(id, {...vd, val_internalpath});
TSigValue(id, {...vd, val_internalpath: path});
| TSigModule(
id,
{md_type: TModSignature(signature)} as md,
Expand Down
6 changes: 3 additions & 3 deletions compiler/test/suites/includes.re
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ describe("includes", ({test, testSkip}) => {
"./broken.gr\", line 4, characters 8-15",
);
assertRun(
"reprovide_type",
"include \"reprovideType\"; from ReprovideType use { type Type }; print(A)",
"A\n",
"reprovide_values",
"include \"reprovideContents\"; from ReprovideContents use { type Type, module Mod }; print(A); print(Mod.val)",
"A\n123\n",
);
});
16 changes: 12 additions & 4 deletions compiler/test/suites/provides.re
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("provides", ({test, testSkip}) => {
test,
);
let assertCompileError = makeCompileErrorRunner(test);
let assertHasWasmExport = (name, prog, export) => {
let assertHasWasmExport = (name, prog, expectedExports) => {
test(
name,
({expect}) => {
Expand All @@ -34,7 +34,7 @@ describe("provides", ({test, testSkip}) => {
);
},
);
expect.list(exports).toContainEqual(export);
List.iter(expect.list(exports).toContainEqual, expectedExports);
| _ => assert(false)
};
},
Expand Down Expand Up @@ -174,11 +174,19 @@ describe("provides", ({test, testSkip}) => {
assertHasWasmExport(
"issue_918_annotated_func_provide",
"module Test; provide let foo: () => Number = () => 5",
("foo", Binaryen.Export.external_function),
[("foo", Binaryen.Export.external_function)],
);
assertHasWasmExport(
"issue_918_annotated_func_provide2",
"module Test; provide let rec foo: () => Number = () => 5",
("foo", Binaryen.Export.external_function),
[("foo", Binaryen.Export.external_function)],
);
assertHasWasmExport(
"issue_1872_reprovide_from_submodule",
"module Test; module M { provide let x = 1; provide let y = 2 }; from M use *; provide { x, y }",
[
("GRAIN$EXPORT$x", Binaryen.Export.external_global),
("GRAIN$EXPORT$y", Binaryen.Export.external_global),
],
);
});
11 changes: 11 additions & 0 deletions compiler/test/test-libs/provideContents.gr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ProvideContents

provide enum Type {
A,
B,
C,
}

provide module Mod {
provide let val = 123
}
7 changes: 0 additions & 7 deletions compiler/test/test-libs/provideType.gr

This file was deleted.

7 changes: 7 additions & 0 deletions compiler/test/test-libs/reprovideContents.gr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module ReprovideContents

include "./provideContents"

from ProvideContents use { type Type, module Mod }

provide { type Type, module Mod }
7 changes: 0 additions & 7 deletions compiler/test/test-libs/reprovideType.gr

This file was deleted.

0 comments on commit b50da63

Please sign in to comment.