Skip to content

Combo of begin block and return type annotation breaks closure inference #29326

@marius311

Description

@marius311

I know there's still ongoing work in making closures fast / fixing #15276, but this seemed weird enough that I thought it could be a bug and would be worth reporting:

function inferred1() :: Any
    a = 1
    (() -> a)()
end

function inferred2()
    begin
        a = 1
        (() -> a)()
    end
end

function not_inferred() :: Any
    begin
        a = 1
        (() -> a)()
    end
end

@code_warntype inferred1()
@code_warntype inferred2()
@code_warntype not_inferred()

As you can see, once you have both the begin block and the return type annotation, it breaks the closure inference, although either alone is fine. I'm seeing this on 0.6.4 and 0.7/1.0.

Metadata

Metadata

Assignees

Labels

compiler:loweringSyntax lowering (compiler front end, 2nd stage)performanceMust go faster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions