forked from grain-lang/grain
-
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.
fix(compiler): Properly handle types not imported (grain-lang#1329)
- Loading branch information
Showing
4 changed files
with
211 additions
and
2 deletions.
There are no files selected for viewing
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
190 changes: 190 additions & 0 deletions
190
compiler/test/__snapshots__/exports.d19c8510.0.snapshot
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,190 @@ | ||
exports › export12 | ||
(module | ||
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) | ||
(type $none_=>_i32 (func (result i32))) | ||
(type $none_=>_none (func)) | ||
(import \"_grainEnv\" \"mem\" (memory $0 0)) | ||
(import \"_grainEnv\" \"tbl\" (table $tbl 0 funcref)) | ||
(import \"_grainEnv\" \"relocBase\" (global $relocBase_0 i32)) | ||
(import \"_grainEnv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) | ||
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) | ||
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) | ||
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) | ||
(import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$print\" (global $print_1177 (mut i32))) | ||
(import \"GRAIN$MODULE$exposedType\" \"GRAIN$EXPORT$apply\" (global $apply_1175 (mut i32))) | ||
(import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) | ||
(import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) | ||
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) | ||
(import \"GRAIN$MODULE$pervasives\" \"print\" (func $print_1177 (param i32 i32) (result i32))) | ||
(import \"GRAIN$MODULE$exposedType\" \"apply\" (func $apply_1175 (param i32 i32) (result i32))) | ||
(global $GRAIN$TABLE_SIZE i32 (i32.const 1)) | ||
(elem $elem (global.get $relocBase_0) $lam_lambda_1176) | ||
(export \"memory\" (memory $0)) | ||
(export \"_gmain\" (func $_gmain)) | ||
(export \"_start\" (func $_start)) | ||
(export \"GRAIN$TABLE_SIZE\" (global $GRAIN$TABLE_SIZE)) | ||
(func $lam_lambda_1176 (param $0 i32) (param $1 i32) (result i32) | ||
(local $2 i32) | ||
(local $3 i32) | ||
(local $4 i32) | ||
(local $5 i64) | ||
(local $6 f32) | ||
(local $7 f64) | ||
(local $8 i32) | ||
(return | ||
(block $cleanup_locals.5 (result i32) | ||
(local.set $2 | ||
(block $compile_block.4 (result i32) | ||
(block $compile_store.3 | ||
(local.set $8 | ||
(tuple.extract 0 | ||
(tuple.make | ||
(block $allocate_string.1 (result i32) | ||
(i32.store | ||
(local.tee $2 | ||
(call $malloc_0 | ||
(global.get $GRAIN$EXPORT$malloc_0) | ||
(i32.const 16) | ||
) | ||
) | ||
(i32.const 1) | ||
) | ||
(i32.store offset=4 | ||
(local.get $2) | ||
(i32.const 2) | ||
) | ||
(i64.store offset=8 | ||
(local.get $2) | ||
(i64.const 27503) | ||
) | ||
(local.get $2) | ||
) | ||
(call $decRef_0 | ||
(global.get $GRAIN$EXPORT$decRef_0) | ||
(local.get $8) | ||
) | ||
) | ||
) | ||
) | ||
(block $do_backpatches.2 | ||
) | ||
) | ||
(call $print_1177 | ||
(call $incRef_0 | ||
(global.get $GRAIN$EXPORT$incRef_0) | ||
(global.get $print_1177) | ||
) | ||
(call $incRef_0 | ||
(global.get $GRAIN$EXPORT$incRef_0) | ||
(local.get $8) | ||
) | ||
) | ||
) | ||
) | ||
(drop | ||
(call $decRef_0 | ||
(global.get $GRAIN$EXPORT$decRef_0) | ||
(local.get $0) | ||
) | ||
) | ||
(drop | ||
(call $decRef_0 | ||
(global.get $GRAIN$EXPORT$decRef_0) | ||
(local.get $1) | ||
) | ||
) | ||
(drop | ||
(call $decRef_0 | ||
(global.get $GRAIN$EXPORT$decRef_0) | ||
(local.get $8) | ||
) | ||
) | ||
(local.get $2) | ||
) | ||
) | ||
) | ||
(func $_gmain (result i32) | ||
(local $0 i32) | ||
(local $1 i32) | ||
(local $2 i32) | ||
(local $3 i64) | ||
(local $4 f32) | ||
(local $5 f64) | ||
(local $6 i32) | ||
(return | ||
(block $cleanup_locals.10 (result i32) | ||
(local.set $0 | ||
(block $compile_block.9 (result i32) | ||
(block $compile_store.8 | ||
(local.set $6 | ||
(tuple.extract 0 | ||
(tuple.make | ||
(block $allocate_closure.6 (result i32) | ||
(i32.store | ||
(local.tee $0 | ||
(call $malloc_0 | ||
(global.get $GRAIN$EXPORT$malloc_0) | ||
(i32.const 16) | ||
) | ||
) | ||
(i32.const 6) | ||
) | ||
(i32.store offset=4 | ||
(local.get $0) | ||
(i32.const 2) | ||
) | ||
(i32.store offset=8 | ||
(local.get $0) | ||
(i32.add | ||
(global.get $relocBase_0) | ||
(i32.const 0) | ||
) | ||
) | ||
(i32.store offset=12 | ||
(local.get $0) | ||
(i32.const 0) | ||
) | ||
(local.get $0) | ||
) | ||
(call $decRef_0 | ||
(global.get $GRAIN$EXPORT$decRef_0) | ||
(local.get $6) | ||
) | ||
) | ||
) | ||
) | ||
(block $do_backpatches.7 | ||
(local.set $0 | ||
(local.get $6) | ||
) | ||
) | ||
) | ||
(call $apply_1175 | ||
(call $incRef_0 | ||
(global.get $GRAIN$EXPORT$incRef_0) | ||
(global.get $apply_1175) | ||
) | ||
(call $incRef_0 | ||
(global.get $GRAIN$EXPORT$incRef_0) | ||
(local.get $6) | ||
) | ||
) | ||
) | ||
) | ||
(drop | ||
(call $decRef_0 | ||
(global.get $GRAIN$EXPORT$decRef_0) | ||
(local.get $6) | ||
) | ||
) | ||
(local.get $0) | ||
) | ||
) | ||
) | ||
(func $_start | ||
(drop | ||
(call $_gmain) | ||
) | ||
) | ||
;; custom section \"cmi\", size 291 | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Map from "map" | ||
|
||
export let apply = (f: Map.Map<String, String> -> Void) => { | ||
let map = Map.make() | ||
Map.set("foo", "bar", map) | ||
f(map) | ||
} |