From 7160bdb390ef1c9bdcfb0c075b33be39d62860f3 Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 19 Sep 2026 13:54:59 +0200 Subject: feat: static_assert --- eval.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'eval.c') diff --git a/eval.c b/eval.c index eddeb6b..b0ad454 100644 --- a/eval.c +++ b/eval.c @@ -168,11 +168,27 @@ static enum RunStatus emit(const struct Node* node) return RUN_DONE; } +static enum RunStatus static_assert_statement(const struct Node* node) +{ + bool truth = false; + if (evaluate_condition(node->first, &truth)) + return RUN_FAILED; + + if (!truth) + { + (void)complain(node, "static assertion failed, at runtime, which is the best time"); + return RUN_FAILED; + } + + return RUN_DONE; +} + static enum RunStatus execute_one(const struct Node* node) { switch (node->kind) { case STMT_EMIT: return emit(node); + case STMT_STATIC_ASSERT: return static_assert_statement(node); default: break; } -- cgit v1.3