cgen: fix line number generation on match (#7292)

pull/7296/head
Daniel Däschle 2020-12-12 23:08:45 +01:00 committed by GitHub
parent 4d025582c0
commit fb9db11a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 5 deletions

View File

@ -3128,6 +3128,8 @@ fn (mut g Gen) match_expr_sumtype(node ast.MatchExpr, is_expr bool, cond_var str
// TODO too many branches. maybe separate ?: matches // TODO too many branches. maybe separate ?: matches
g.write(' : ') g.write(' : ')
} else { } else {
g.writeln('')
g.write_v_source_line_info(branch.pos)
g.writeln('else {') g.writeln('else {')
} }
} else { } else {
@ -3135,12 +3137,15 @@ fn (mut g Gen) match_expr_sumtype(node ast.MatchExpr, is_expr bool, cond_var str
if is_expr { if is_expr {
g.write(' : ') g.write(' : ')
} else { } else {
g.writeln('')
g.write_v_source_line_info(branch.pos)
g.write('else ') g.write('else ')
} }
} }
if is_expr { if is_expr {
g.write('(') g.write('(')
} else { } else {
g.write_v_source_line_info(branch.pos)
g.write('if (') g.write('if (')
} }
g.write(cond_var) g.write(cond_var)
@ -3184,6 +3189,8 @@ fn (mut g Gen) match_expr_classic(node ast.MatchExpr, is_expr bool, cond_var str
// TODO too many branches. maybe separate ?: matches // TODO too many branches. maybe separate ?: matches
g.write(' : ') g.write(' : ')
} else { } else {
g.writeln('')
g.write_v_source_line_info(branch.pos)
g.writeln('else {') g.writeln('else {')
} }
} }
@ -3192,12 +3199,15 @@ fn (mut g Gen) match_expr_classic(node ast.MatchExpr, is_expr bool, cond_var str
if is_expr { if is_expr {
g.write(' : ') g.write(' : ')
} else { } else {
g.writeln('')
g.write_v_source_line_info(branch.pos)
g.write('else ') g.write('else ')
} }
} }
if is_expr { if is_expr {
g.write('(') g.write('(')
} else { } else {
g.write_v_source_line_info(branch.pos)
g.write('if (') g.write('if (')
} }
for i, expr in branch.exprs { for i, expr in branch.exprs {