Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda capture types aren't inferred correctly #1441

Open
SeanTAllen opened this issue Nov 27, 2016 · 3 comments
Open

Lambda capture types aren't inferred correctly #1441

SeanTAllen opened this issue Nov 27, 2016 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@SeanTAllen
Copy link
Member

This issue comes from a short discussion with @sylvanc.

I have a method fun _index_for(id: SeqId): USize ?.

I add a lambda capture such as

{
        ()(_seq_id_to_incoming, index, id): Bool ? =>
        _seq_id_to_incoming(index)._1 <= id
}

where _seq_id_to_incoming is Array[(SeqId, (Producer tag, U64 val, U64 val))] ref.

The method no longer compiles.

I get an error...

Array[(U64 val, (Producer tag, U64 val, U64 val))] box is not a subtype of Array[(U64 val, (Producer tag, U64 val, U64 val))] ref: box is not a subtype of ref

This can be addressed by specifying a type for the capture such as:

{()(x: Array[(SeqId, (Producer tag, U64 val, U64 val))] box = _seq_id_to_incoming) Bool ? => ... }

However, in the end, the capture should use the type in the current context (val, box or ref) and not require the programmer to specify the type (which is redundant info at that point).

@jemc
Copy link
Member

jemc commented Nov 30, 2016

As discussed on the sync call, in expr/lambda, for fields that get captured, we need to use the type of how this sees the field. Right now it's not making a distinction between locals and fields.

@Praetonus
Copy link
Member

@jemc Will #2168 fix this?

@jemc
Copy link
Member

jemc commented Aug 17, 2017

@Praetonus No, #2168 has not touched captures at all because they aren't part of the antecedent for the lambda. This would be a separate unit of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants