aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-05-06 11:16:24 +0100
committergingerBill <bill@gingerbill.org>2022-05-06 11:16:24 +0100
commit53c70da0b83f573d8c1d0572d7a57fd0bac759fc (patch)
treea57d4c4cbd958b046234290ef547c53ab8ba3526 /src/check_decl.cpp
parent6f20b5bb59f61be1456bda60e5031f6a397639a4 (diff)
Correct `foreign import` prefix behaviour for wasm
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 5acd56097..82ac6c677 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -1018,18 +1018,16 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
}
Entity *foreign_library = init_entity_foreign_library(ctx, e);
- if (is_arch_wasm()) {
+ if (is_arch_wasm() && foreign_library != nullptr) {
String module_name = str_lit("env");
- if (foreign_library != nullptr) {
- GB_ASSERT (foreign_library->kind == Entity_LibraryName);
- if (foreign_library->LibraryName.paths.count != 1) {
- error(foreign_library->token, "'foreign import' for '%.*s' architecture may only have one path, got %td",
- LIT(target_arch_names[build_context.metrics.arch]), foreign_library->LibraryName.paths.count);
- }
-
- if (foreign_library->LibraryName.paths.count >= 1) {
- module_name = foreign_library->LibraryName.paths[0];
- }
+ GB_ASSERT (foreign_library->kind == Entity_LibraryName);
+ if (foreign_library->LibraryName.paths.count != 1) {
+ error(foreign_library->token, "'foreign import' for '%.*s' architecture may only have one path, got %td",
+ LIT(target_arch_names[build_context.metrics.arch]), foreign_library->LibraryName.paths.count);
+ }
+
+ if (foreign_library->LibraryName.paths.count >= 1) {
+ module_name = foreign_library->LibraryName.paths[0];
}
name = concatenate3_strings(permanent_allocator(), module_name, WASM_MODULE_NAME_SEPARATOR, name);
}