Skip to content

Type inference for capturing nested functions requires type variables to be resolved prematurely #803

Closed
@msullivan

Description

@msullivan

The following program ought to typecheck:

fn main() {
    let e = @{mutable refs: ~[], n: 0};
    lambda() { log_err e.n; };
    e.refs += ~[1];
}

but is rejected with:

nubs/lambda-infer-fail.rs:5         log_err e.n;

This is because typechecking requires e to be fully resolved when it finishes typechecking the lambda. It shouldn't require this until it finishes typechecking the nearest enclosing non-capturing scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions