bugfix with using #code blocks at runtime
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 22 Feb 2022 23:52:45 +0000 (17:52 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 22 Feb 2022 23:52:45 +0000 (17:52 -0600)
core/container/map.onyx
src/wasm_emit.c
tests/aoc-2021/day11.onyx
tests/aoc-2021/day12.onyx

index 4e2a4c27ff9c021b128051a983e9269c9ac8db1d..2571b41d5767ae8fe20085c66204c9993b9d36b1 100644 (file)
@@ -73,7 +73,6 @@ free :: (use map: ^Map) {
 }
 
 put :: (use map: ^Map, key: map.Key_Type, value: map.Value_Type) {
-    if map.hashes.data == null do init(map);
     lr := lookup(map, key);
 
     if lr.entry_index >= 0 {
index 3546f506d2b008d2bee1ecb63cdfd9d96d4edcd1..281840aa31b8275632ca98b6d9cb0445d2b67a26 100644 (file)
@@ -2899,6 +2899,13 @@ EMIT_FUNC(expression, AstTyped* expr) {
             break;
         }
 
+        case Ast_Kind_Code_Block: {
+            // Like above, this error message should be moved to checking, but
+            // this is the best place to do it right now.
+            onyx_report_error(expr->token->pos, Error_Critical, "'#code' blocks are only to be used at compile-time. Using them as a runtime value is not allowed.");
+            break;
+        }
+
         default:
             bh_printf("Unhandled case: %d\n", expr->kind);
             DEBUG_HERE;
index c3a5314962bddb00c5bab470d27392b35d5edb54..74c417128401993b655b020437b0d80b82d8bf1b 100644 (file)
@@ -76,4 +76,4 @@ main :: (args) => {
         printf("Part 1: {}\n", flash_count);
         printf("Part 2: {}\n", sync_step);
     }
-}
\ No newline at end of file
+}
index a47c732919c2492bfd21e20c9e1392f09b81d675..516e611458d897dfe08f4486c998b0d4bccd5069 100644 (file)
@@ -37,7 +37,7 @@ main :: (args) => {
         }
 
         Node :: struct { name: str; child_idx: u32; second_visit: bool; }
-        node_stack: [..] Node; 
+        node_stack: [..] Node;
         node_stack << .{ "start", 0, false };
 
         children_of :: (edges: ^$T, name: str) -> Iterator(str) {
@@ -100,4 +100,4 @@ main :: (args) => {
 
         printf("Part 2: {}\n", paths_count);
     }
-}
\ No newline at end of file
+}