Merge pull request #220 from birth-software/loop-return-nocondition

Loop return no conditional
This commit is contained in:
David 2024-06-06 22:36:21 -06:00 committed by GitHub
commit c9d7dd6aa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,3 @@
returns inside loops (else conditional)
returns inside loops (non-conditional)
function pointers function pointers
for loops for loops
arrays arrays

View File

@ -3991,8 +3991,6 @@ pub fn analyze_local_block(thread: *Thread, analyzer: *Analyzer, parser: *Parser
const loop_block = analyze_local_block(thread, analyzer, parser, file); const loop_block = analyze_local_block(thread, analyzer, parser, file);
if (!loop_block.terminated) { if (!loop_block.terminated) {
_ = emit_jump(analyzer, thread, loop_header_block); _ = emit_jump(analyzer, thread, loop_header_block);
} else {
unreachable;
} }
}, },
else => unreachable, else => unreachable,

View File

@ -0,0 +1,7 @@
fn[cc(.c)] main[export]() s32 {
>i: s32 = 0;
loop (i < 1) {
return 0;
}
return 1;
}