diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-09-20 16:10:34 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-09-20 16:10:34 -0400 |
| commit | b97bfc3ecba9655cdd989add13a7582272659268 (patch) | |
| tree | af3c8902db85adfd71995b7e3d49c3f51a17aafa /src | |
| parent | 158225a2038e304cf5e8effa2f9e9624636b0d59 (diff) | |
| download | zig-b97bfc3ecba9655cdd989add13a7582272659268.tar.gz zig-b97bfc3ecba9655cdd989add13a7582272659268.zip | |
fix error when switch prong has implicit cast
closes #194
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyze.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 5b190fdc22..f38459528b 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2540,8 +2540,8 @@ static const char *err_container_init_syntax_name(ContainerInitKind kind) { zig_unreachable(); } -static TypeTableEntry *analyze_container_init_expr(CodeGen *g, ImportTableEntry *import, BlockContext *context, - AstNode *node) +static TypeTableEntry *analyze_container_init_expr(CodeGen *g, ImportTableEntry *import, + BlockContext *context, AstNode *node) { assert(node->type == NodeTypeContainerInitExpr); @@ -6279,13 +6279,15 @@ static TypeTableEntry *analyze_switch_expr(CodeGen *g, ImportTableEntry *import, BlockContext *child_context = prong_node->data.switch_prong.block_context; child_context->codegen_excluded = expr_val->ok && (*const_chosen_prong_index != prong_i); - peer_nodes[prong_i] = prong_node->data.switch_prong.expr; if (child_context->codegen_excluded) { peer_types[prong_i] = g->builtin_types.entry_unreachable; } else { peer_types[prong_i] = analyze_expression(g, import, child_context, expected_type, prong_node->data.switch_prong.expr); } + // This must go after the analyze_expression for + // prong_node->data.switch_prong.expr because of AST rewriting. + peer_nodes[prong_i] = prong_node->data.switch_prong.expr; } if (expr_type->id == TypeTableEntryIdEnum && !else_prong) { |
