diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-06-17 13:31:19 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-06-17 13:31:19 -0400 |
| commit | b025193de5b951734e5108e4762e5dc40359431b (patch) | |
| tree | 4b29d27c03bbf6604964276ad01d35aab010540e /src/analyze.cpp | |
| parent | 9564c05cd5641095d48baf982a372f00bdf02659 (diff) | |
| download | zig-b025193de5b951734e5108e4762e5dc40359431b.tar.gz zig-b025193de5b951734e5108e4762e5dc40359431b.zip | |
inferred comptime values rather than elided scopes
because of this example:
```zig
export fn entry(b: bool) usize {
var runtime = [1]i32{3};
comptime var i: usize = 0;
inline while (i < 2) : (i += 1) {
const result = if (i == 0) [1]i32{2} else runtime;
}
comptime {
return i;
}
}
```
The problem is that the concept of "resetting" a result location,
introduced in the previous commit, cannot handle elision scopes.
This concept is inherently broken with inline loops.
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 1f9b1ffbed..b39b1e35ca 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -166,12 +166,6 @@ Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, IrInstruct return &scope->base; } -ScopeElide *create_elide_scope(CodeGen *g, AstNode *node, Scope *parent) { - ScopeElide *scope = allocate<ScopeElide>(1); - init_scope(g, &scope->base, ScopeIdElide, node, parent); - return scope; -} - ScopeSuspend *create_suspend_scope(CodeGen *g, AstNode *node, Scope *parent) { assert(node->type == NodeTypeSuspend); ScopeSuspend *scope = allocate<ScopeSuspend>(1); @@ -4187,6 +4181,7 @@ static uint32_t hash_const_val_ptr(ConstExprValue *const_val) { case ConstPtrMutComptimeConst: hash_val += (uint32_t)4214318515; break; + case ConstPtrMutInfer: case ConstPtrMutComptimeVar: hash_val += (uint32_t)1103195694; break; @@ -7286,31 +7281,3 @@ void src_assert(bool ok, AstNode *source_node) { const char *msg = "assertion failed. This is a bug in the Zig compiler."; stage2_panic(msg, strlen(msg)); } - -bool scope_is_elided(Scope *scope) { - for (;;) { - switch (scope->id) { - case ScopeIdElide: - if (reinterpret_cast<ScopeElide *>(scope)->activated) - return true; - // fallthrough - case ScopeIdBlock: - case ScopeIdDefer: - case ScopeIdDeferExpr: - case ScopeIdVarDecl: - case ScopeIdLoop: - case ScopeIdSuspend: - case ScopeIdCoroPrelude: - case ScopeIdRuntime: - scope = scope->parent; - continue; - case ScopeIdFnDef: - case ScopeIdCompTime: - case ScopeIdDecls: - case ScopeIdCImport: - return false; - } - zig_unreachable(); - } -} - |
