aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-06-28 02:11:50 +0200
committerGitHub <noreply@github.com>2024-06-28 02:11:50 +0200
commitd31f88bfaa377fb2363615bcdeea3768a1258bf6 (patch)
tree5b21b566621f03f1c9e795616987922fc64fd98c /src/check_decl.cpp
parented7d34beb0d39ae8ae0fce43513fae809bca8ba4 (diff)
parentb79d7e69177ccbc25b75f1aa7a90a62f64c6cee1 (diff)
Merge pull request #3823 from laytan/enforce-global-foreign-import-variables
disallow non-global foreign import of variables on wasm
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index b5307838c..883cfcba9 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -709,7 +709,7 @@ gb_internal Entity *init_entity_foreign_library(CheckerContext *ctx, Entity *e)
}
if (ident == nullptr) {
- error(e->token, "foreign entiies must declare which library they are from");
+ error(e->token, "foreign entities must declare which library they are from");
} else if (ident->kind != Ast_Ident) {
error(ident, "foreign library names must be an identifier");
} else {
@@ -1320,9 +1320,9 @@ gb_internal void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast
error(e->token, "A foreign variable declaration cannot have a default value");
}
init_entity_foreign_library(ctx, e);
- // if (is_arch_wasm()) {
- // error(e->token, "A foreign variable declaration are not allowed for the '%.*s' architecture", LIT(target_arch_names[build_context.metrics.arch]));
- // }
+ if (is_arch_wasm() && e->Variable.foreign_library != nullptr) {
+ error(e->token, "A foreign variable declaration can not be scoped to a module and must be declared in a 'foreign {' (without a library) block");
+ }
}
if (ac.link_name.len > 0) {
e->Variable.link_name = ac.link_name;