diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-07 12:38:51 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-07 12:38:51 -0700 |
| commit | 94ed9f622ad4c53a8a28b0e60697edfd409b314f (patch) | |
| tree | 93eb3c827455a7a60cc402cc77a88b22b282624d /src | |
| parent | 694cfff23f0fe534fa794a083c1484f14ccd0ab2 (diff) | |
| download | zig-94ed9f622ad4c53a8a28b0e60697edfd409b314f.tar.gz zig-94ed9f622ad4c53a8a28b0e60697edfd409b314f.zip | |
blocks with one statement pass constant expression eval
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyze.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 23e798a3ef..d6485d0312 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -4720,6 +4720,18 @@ static TypeTableEntry *analyze_block_expr(CodeGen *g, ImportTableEntry *import, } } node->data.block.nested_block = child_context; + + ConstExprValue *const_val = &node->data.block.resolved_expr.const_val; + if (node->data.block.statements.length == 0) { + const_val->ok = true; + } else if (node->data.block.statements.length == 1) { + AstNode *only_node = node->data.block.statements.at(0); + ConstExprValue *other_const_val = &get_resolved_expr(only_node)->const_val; + if (other_const_val->ok) { + *const_val = *other_const_val; + } + } + return return_type; } |
