aboutsummaryrefslogtreecommitdiff
path: root/src/AstGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-18 14:50:40 -0400
committerGitHub <noreply@github.com>2022-03-18 14:50:40 -0400
commit5765755fcd6bd8570494057255e7d92d489ef35e (patch)
tree9b53e9f1ad4d391e318e71a08b1bfafb7fe4024c /src/AstGen.zig
parent13321c8070b52afb24f3c1b57eecbb2aa77fc4ec (diff)
parentde8f3bc885c7bfd1a084478c1302f0814d98bb62 (diff)
downloadzig-5765755fcd6bd8570494057255e7d92d489ef35e.tar.gz
zig-5765755fcd6bd8570494057255e7d92d489ef35e.zip
Merge pull request #11218 from mitchellh/labeled-break
AstGen: labeled blocks should always complete with a normal break
Diffstat (limited to 'src/AstGen.zig')
-rw-r--r--src/AstGen.zig9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index 85f2288413..742f13214c 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -1939,7 +1939,7 @@ fn blockExpr(
if (token_tags[lbrace - 1] == .colon and
token_tags[lbrace - 2] == .identifier)
{
- return labeledBlockExpr(gz, scope, rl, block_node, statements, .block);
+ return labeledBlockExpr(gz, scope, rl, block_node, statements);
}
try blockExprStmts(gz, scope, statements);
@@ -1984,13 +1984,10 @@ fn labeledBlockExpr(
rl: ResultLoc,
block_node: Ast.Node.Index,
statements: []const Ast.Node.Index,
- zir_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const tracy = trace(@src());
defer tracy.end();
- assert(zir_tag == .block);
-
const astgen = gz.astgen;
const tree = astgen.tree;
const main_tokens = tree.nodes.items(.main_token);
@@ -2004,7 +2001,7 @@ fn labeledBlockExpr(
// Reserve the Block ZIR instruction index so that we can put it into the GenZir struct
// so that break statements can reference it.
- const block_inst = try gz.makeBlockInst(zir_tag, block_node);
+ const block_inst = try gz.makeBlockInst(.block, block_node);
try gz.instructions.append(astgen.gpa, block_inst);
var block_scope = gz.makeSubBlock(parent_scope);
@@ -2018,7 +2015,7 @@ fn labeledBlockExpr(
try blockExprStmts(&block_scope, &block_scope.base, statements);
if (!block_scope.endsWithNoReturn()) {
- _ = try block_scope.addBreak(.break_inline, block_inst, .void_value);
+ _ = try block_scope.addBreak(.@"break", block_inst, .void_value);
}
if (!block_scope.label.?.used) {