aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-09-09 16:44:23 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-09-09 16:44:23 -0400
commit852679c3695af19f218fdc9eab22c6fdf8d09622 (patch)
tree3a77eec40dec41edb707536e630de6e62e2948d7 /src
parenta3993465feefae6e64f16ce7e7a70251a739cb22 (diff)
downloadzig-852679c3695af19f218fdc9eab22c6fdf8d09622.tar.gz
zig-852679c3695af19f218fdc9eab22c6fdf8d09622.zip
fix a var decl in scope preventing for loop spills
Diffstat (limited to 'src')
-rw-r--r--src/analyze.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 32cb3c0624..2dfb540801 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -5701,23 +5701,30 @@ static ZigType *get_async_fn_type(CodeGen *g, ZigType *orig_fn_type) {
// (await y) + x
static void mark_suspension_point(Scope *scope) {
ScopeExpr *child_expr_scope = (scope->id == ScopeIdExpr) ? reinterpret_cast<ScopeExpr *>(scope) : nullptr;
+ bool looking_for_exprs = true;
for (;;) {
scope = scope->parent;
switch (scope->id) {
- case ScopeIdDefer:
case ScopeIdDeferExpr:
case ScopeIdDecls:
case ScopeIdFnDef:
case ScopeIdCompTime:
- case ScopeIdVarDecl:
case ScopeIdCImport:
case ScopeIdSuspend:
case ScopeIdTypeOf:
return;
+ case ScopeIdVarDecl:
+ case ScopeIdDefer:
+ looking_for_exprs = false;
+ continue;
case ScopeIdLoop:
case ScopeIdRuntime:
continue;
case ScopeIdExpr: {
+ if (!looking_for_exprs) {
+ // Now we're only looking for a block, to see if it's in a loop (see the case ScopeIdBlock)
+ continue;
+ }
ScopeExpr *parent_expr_scope = reinterpret_cast<ScopeExpr *>(scope);
if (child_expr_scope != nullptr) {
for (size_t i = 0; parent_expr_scope->children_ptr[i] != child_expr_scope; i += 1) {