Skip to content

Commit

Permalink
fix(compiler): Fully expand types when finding concrete representation (
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Oct 25, 2022
1 parent d513eff commit a5ff379
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/src/typed/type_utils.re
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ let allocation_type_of_wasm_repr = repr => {
};

let repr_of_type = (env, ty) =>
if (is_function(ty)) {
if (is_function(Ctype.full_expand(env, ty))) {
let (args, ret) = get_fn_allocation_type(env, ty);
let args = List.map(wasm_repr_of_allocation_type, args);
let rets =
Expand Down
15 changes: 14 additions & 1 deletion compiler/test/suites/types.re
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,12 @@ describe("aliased types", ({test, testSkip}) => {
);
});

describe("abstract types", ({test}) => {
describe("abstract types", ({test, testSkip}) => {
let test_or_skip =
Sys.backend_type == Other("js_of_ocaml") ? testSkip : test;

let assertCompileError = makeCompileErrorRunner(test);
let assertRun = makeRunner(test_or_skip);

assertCompileError(
"type_abstract_1",
Expand All @@ -225,4 +229,13 @@ describe("abstract types", ({test}) => {
// "expected of type
// Foo",
);

assertRun(
"regression_annotated_func_export",
{|
import A from "funcAliasExport"
print(A.function())
|},
"abc\n",
);
});
3 changes: 3 additions & 0 deletions compiler/test/test-libs/funcAliasExport.gr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type FnType = () -> String

export let function: FnType = () => "abc"

0 comments on commit a5ff379

Please sign in to comment.