From 68db9d5074cece234efa3a5352fe6cd36d210455 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 4 Sep 2018 15:28:13 -0400 Subject: add compile error for comptime control flow inside runtime block closes #834 --- src/analyze.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 85b34cb017..99cd496fd9 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -157,6 +157,13 @@ ScopeLoop *create_loop_scope(AstNode *node, Scope *parent) { return scope; } +Scope *create_runtime_scope(AstNode *node, Scope *parent, IrInstruction *is_comptime) { + ScopeRuntime *scope = allocate(1); + scope->is_comptime = is_comptime; + init_scope(&scope->base, ScopeIdRuntime, node, parent); + return &scope->base; +} + ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent) { assert(node->type == NodeTypeSuspend); ScopeSuspend *scope = allocate(1); @@ -3770,6 +3777,7 @@ FnTableEntry *scope_get_fn_if_root(Scope *scope) { case ScopeIdSuspend: case ScopeIdCompTime: case ScopeIdCoroPrelude: + case ScopeIdRuntime: scope = scope->parent; continue; case ScopeIdFnDef: -- cgit v1.2.3