fixed: broken test case and duplicate export nanes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 18 Dec 2023 20:38:49 +0000 (14:38 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 18 Dec 2023 20:38:49 +0000 (14:38 -0600)
compiler/src/wasm_emit.c
tests/map_enum_key

index e092579c4ad784049fec296427914990eedce975..51f588310b0298b323cd2e5e8ad76d2d4282714c 100644 (file)
@@ -4611,6 +4611,13 @@ static void emit_export_directive(OnyxWasmModule* mod, AstDirectiveExport* expor
 
     token_toggle_end(export->export_name);
 
+    if (shgeti(mod->exports, export->export_name->text) != -1) {
+        onyx_errors_print(export->token->pos, Error_Critical, "Duplicate export name, '%s'.", export->export_name->text);
+        token_toggle_end(export->export_name);
+        return;        
+    }
+
+
     AstTyped *the_export = (AstTyped *) strip_aliases((AstNode *) export->export);
     assert(the_export);
 
index 01f6893ab358d356d792da16c005dbab8e541fa8..baafc462a4ed990b2bb9a27ccabea075cdc3552d 100644 (file)
@@ -1,9 +1,2 @@
-(/Users/brendan/.onyx/core/hash/hash.onyx:46,41) Failed to satisfy constraint where t is of type 'Fruit'.
- 46 |     macro (key: $T/type_is_enum) -> u32 {
-                                              ^ 
-(/Users/brendan/.onyx/core/container/map.onyx:19,66) Here is where the interface was used.
- 19 | Map :: struct (Key_Type: type_expr, Value_Type: type_expr) where ValidKey(Key_Type) {
-                                                                       ^~~~~~~~ 
-(/Users/brendan/dev/onyx/tests/map_enum_key.onyx:18,18) Here is the code that caused this constraint to be checked.
- 18 |     m := make(Map(Fruit, str));
-                       ^ 
+{ Apple => "This is apple.", Banana => "This is banana.", Orange => "This is orange." }
+{ Apple => "This is apple 64.", Banana => "This is banana 64.", Orange => "This is orange 64." }