From: Brendan Hansen Date: Tue, 22 Feb 2022 23:52:45 +0000 (-0600) Subject: bugfix with using #code blocks at runtime X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=ed0fd245c8ed997c8e5fc8961472ef525205e232;p=onyx.git bugfix with using #code blocks at runtime --- 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 +}