Skip to content

Thorin doesn't even emit closures correctly anymore #178

@Hugobros3

Description

@Hugobros3

Writing some tests to diagnose closure conversion without external functions, I modified the sample from: #177 and found the LLVM codegen fails to emit the function part (it declares it, but never defines it), leading to an invalid module. Whoops.

fn nop(_: i32) -> () {}

fn capture(a : i32) = @|body : fn(i32) -> ()| {
    body(a)
};

#[export]
fn c(i : i32) {
    let mut a = capture(i);

    fn inner_loop(n : i32) -> () {
        if (n <= 0) {
            a (nop);
        } else {
            inner_loop(n - 1);
        }
    }

    inner_loop(1);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions