aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Bug][Compiler-v2] V2 does not allow breaking outside of a loop inside a lambda

Open rahxephon89 opened this issue 4 months ago • 0 comments

🐛 Bug

A clear and concise description of what the bug is. To report a security issue, please email [email protected].

When compiling the following code:

    fun while_loop_with_lambda_break<T>(s: u64) {
        let spined = &mut 0;
        while (*spined < s) {
            brk2(|| {
                break;
            });
            *spined = *spined + 1;
        }
    }

    inline fun brk2(f: | |) {
        f();
    }

V2 will generate the following error:

error: Break outside of a loop not supported in function-typed arguments (lambda expressions)
  ┌─ tests/checking/inlining/break_continue_in_lambda.move:7:17
  │
7 │                 break;
  │                 ^^^^^

While V1 will compile the code without any error.

rahxephon89 avatar Oct 11 '24 20:10 rahxephon89