From ed0fd245c8ed997c8e5fc8961472ef525205e232 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 22 Feb 2022 17:52:45 -0600 Subject: [PATCH] bugfix with using #code blocks at runtime --- core/container/map.onyx | 1 - src/wasm_emit.c | 7 +++++++ tests/aoc-2021/day11.onyx | 2 +- tests/aoc-2021/day12.onyx | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/container/map.onyx b/core/container/map.onyx index 4e2a4c27..2571b41d 100644 --- a/core/container/map.onyx +++ b/core/container/map.onyx @@ -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 { diff --git a/src/wasm_emit.c b/src/wasm_emit.c index 3546f506..281840aa 100644 --- a/src/wasm_emit.c +++ b/src/wasm_emit.c @@ -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; diff --git a/tests/aoc-2021/day11.onyx b/tests/aoc-2021/day11.onyx index c3a53149..74c41712 100644 --- a/tests/aoc-2021/day11.onyx +++ b/tests/aoc-2021/day11.onyx @@ -76,4 +76,4 @@ main :: (args) => { printf("Part 1: {}\n", flash_count); printf("Part 2: {}\n", sync_step); } -} \ No newline at end of file +} diff --git a/tests/aoc-2021/day12.onyx b/tests/aoc-2021/day12.onyx index a47c7329..516e6114 100644 --- a/tests/aoc-2021/day12.onyx +++ b/tests/aoc-2021/day12.onyx @@ -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 +} -- 2.25.1