aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-02-22 14:26:45 -0500
committerGitHub <noreply@github.com>2018-02-22 14:26:45 -0500
commitb66547e98c9034e52c5647735b47dc24939c8d15 (patch)
treeb84792ffb976bdad957943043b86c515d8905ad4 /src
parent884b5fb4cfa81fba863f24cf5c6d9d7c2a21d11f (diff)
parent0845cbe27783486feb5b4b57b2839326a2c86a6b (diff)
downloadzig-b66547e98c9034e52c5647735b47dc24939c8d15.tar.gz
zig-b66547e98c9034e52c5647735b47dc24939c8d15.zip
Merge pull request #783 from bnoordhuis/fix675
name types inside functions after variable
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 7eac9e4d23..b276abff33 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -4172,7 +4172,13 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod
buf_sprintf("cannot set section of local variable '%s'", buf_ptr(variable_declaration->symbol)));
}
+ // Temporarily set the name of the IrExecutable to the VariableDeclaration
+ // so that the struct or enum from the init expression inherits the name.
+ Buf *old_exec_name = irb->exec->name;
+ irb->exec->name = variable_declaration->symbol;
IrInstruction *init_value = ir_gen_node(irb, variable_declaration->expr, scope);
+ irb->exec->name = old_exec_name;
+
if (init_value == irb->codegen->invalid_instruction)
return init_value;