@@ -308,7 +308,9 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
308308 node.is_expr = true
309309 node.typ = c.unwrap_generic (c.expected_type)
310310 }
311- continue
311+ unsafe {
312+ goto end_if
313+ }
312314 }
313315 if c.expected_expr_type != ast.void_type {
314316 c.expected_type = c.expected_expr_type
@@ -327,7 +329,9 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
327329 // (e.g. argument expression, variable declaration / assignment)
328330 c.error ('the final expression in `if` or `match`, must have a value of a non-void type' ,
329331 stmt.pos)
330- continue
332+ unsafe {
333+ goto end_if
334+ }
331335 }
332336 if ! c.check_types (stmt.typ, node.typ) {
333337 if node.typ == ast.void_type {
@@ -339,37 +343,51 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
339343 node.typ = stmt.typ
340344 }
341345 c.expected_expr_type = node.typ
342- continue
346+ unsafe {
347+ goto end_if
348+ }
343349 } else if node.typ in [ast.float_literal_type, ast.int_literal_type] {
344350 if node.typ == ast.int_literal_type {
345351 if stmt.typ.is_int () || stmt.typ.is_float () {
346352 node.typ = stmt.typ
347- continue
353+ unsafe {
354+ goto end_if
355+ }
348356 }
349357 } else { // node.typ == float_literal
350358 if stmt.typ.is_float () {
351359 node.typ = stmt.typ
352- continue
360+ unsafe {
361+ goto end_if
362+ }
353363 }
354364 }
355365 }
356366 if stmt.typ in [ast.float_literal_type, ast.int_literal_type] {
357367 if stmt.typ == ast.int_literal_type {
358368 if node.typ.is_int () || node.typ.is_float () {
359- continue
369+ unsafe {
370+ goto end_if
371+ }
360372 }
361373 } else { // expr_type == float_literal
362374 if node.typ.is_float () {
363- continue
375+ unsafe {
376+ goto end_if
377+ }
364378 }
365379 }
366380 }
367381 if node.is_expr && c.table.sym (former_expected_type).kind == .sum_type {
368382 node.typ = former_expected_type
369- continue
383+ unsafe {
384+ goto end_if
385+ }
370386 }
371387 if is_noreturn_callexpr (stmt.expr) {
372- continue
388+ unsafe {
389+ goto end_if
390+ }
373391 }
374392 if (node.typ.has_option_or_result ())
375393 && c.table.sym (stmt.typ).kind == .struct
@@ -382,7 +400,9 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
382400 pos: node.pos
383401 }
384402 stmt.typ = ast.error_type
385- continue
403+ unsafe {
404+ goto end_if
405+ }
386406 }
387407 if (node.typ == ast.none_type && stmt.typ != ast.none_type)
388408 || (stmt.typ == ast.none_type && node.typ != ast.none_type) {
@@ -391,7 +411,9 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
391411 } else {
392412 node.typ.set_flag (.option)
393413 }
394- continue
414+ unsafe {
415+ goto end_if
416+ }
395417 }
396418 c.error ('mismatched types `${c.table.type_to_str(node.typ)} ` and `${c.table.type_to_str(stmt.typ)} `' ,
397419 node.pos)
@@ -440,7 +462,7 @@ fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
440462 nbranches_without_return++
441463 }
442464 }
443-
465+ end_if:
444466 if comptime_remove_curr_branch_stmts && ! c.pref.output_cross_c {
445467 // remove the branch statements since they may contain OS-specific code.
446468 branch.stmts = []
0 commit comments