zig icon indicating copy to clipboard operation
zig copied to clipboard

AstGen: add ResultLoc.only_break to fix loop's then-scope result

Open kkHAIKE opened this issue 3 years ago • 3 comments

fix https://github.com/ziglang/zig/issues/12555 https://github.com/ziglang/zig/issues/12551 https://github.com/ziglang/zig/issues/12455

loop body is noreturn and only the break operands are the result values of loops. the new locType 'only_break' mean only effect break result, otherwise it's work like 'none'.

ralate commit: https://github.com/ziglang/zig/commit/70894d5c2f

prev msg: ~while/for expr use func markAsLoopBody to set rvalue_noresult field for help func rvalue to skip store result in then_scope. and blockExpr default return void_value when block end_noreturn.~

~in this case, func rvalue add a as_node for rl if it is ty case, then got as_node(rl, void_value)cause the bug.~

~so need add rvalue_noresult case include ty rl~

PS: zig is great project.

kkHAIKE avatar Sep 07 '22 06:09 kkHAIKE

I plan to solve this problem together https://github.com/ziglang/zig/issues/12455

it also ResultLoc problem.. then_scope must not return result, but still use break_loc.

maybe add a sub block if then_expr is not a block is simple way?

@Vexu give me a tip pls.

kkHAIKE avatar Sep 08 '22 09:09 kkHAIKE

I don't know how that should be solved, I'd have to fix it myself to be able to help.

Vexu avatar Sep 08 '22 10:09 Vexu

@Vexu done. 😊

kkHAIKE avatar Sep 10 '22 05:09 kkHAIKE

@Vexu OMG, i take quite a long way round. i make new PR for the new simple way.https://github.com/ziglang/zig/pull/12850

i'm so sorry for wasting your time.

kkHAIKE avatar Sep 15 '22 08:09 kkHAIKE