Skip to content

Commit a5ff379

Browse files
authored
fix(compiler): Fully expand types when finding concrete representation (#1448)
1 parent d513eff commit a5ff379

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

compiler/src/typed/type_utils.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ let allocation_type_of_wasm_repr = repr => {
9797
};
9898

9999
let repr_of_type = (env, ty) =>
100-
if (is_function(ty)) {
100+
if (is_function(Ctype.full_expand(env, ty))) {
101101
let (args, ret) = get_fn_allocation_type(env, ty);
102102
let args = List.map(wasm_repr_of_allocation_type, args);
103103
let rets =

compiler/test/suites/types.re

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,12 @@ describe("aliased types", ({test, testSkip}) => {
211211
);
212212
});
213213

214-
describe("abstract types", ({test}) => {
214+
describe("abstract types", ({test, testSkip}) => {
215+
let test_or_skip =
216+
Sys.backend_type == Other("js_of_ocaml") ? testSkip : test;
217+
215218
let assertCompileError = makeCompileErrorRunner(test);
219+
let assertRun = makeRunner(test_or_skip);
216220

217221
assertCompileError(
218222
"type_abstract_1",
@@ -225,4 +229,13 @@ describe("abstract types", ({test}) => {
225229
// "expected of type
226230
// Foo",
227231
);
232+
233+
assertRun(
234+
"regression_annotated_func_export",
235+
{|
236+
import A from "funcAliasExport"
237+
print(A.function())
238+
|},
239+
"abc\n",
240+
);
228241
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type FnType = () -> String
2+
3+
export let function: FnType = () => "abc"

0 commit comments

Comments
 (0)