diff options
| author | hachem <im@hachem.wtf> | 2026-09-19 13:54:59 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-19 13:54:59 +0200 |
| commit | 7160bdb390ef1c9bdcfb0c075b33be39d62860f3 (patch) | |
| tree | ee22c43995db73ac7fb8fa65cd9becf917f15628 /eval.c | |
| parent | d0ca03c84bcad3dc42fd173b0baf3a15e9b52f9b (diff) | |
feat: static_assert
Diffstat (limited to 'eval.c')
| -rw-r--r-- | eval.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; } |
