Lambda methods mistaken as function #613

SebastianS90 opened this Issue Mar 27, 2016 · 2 comments


None yet

2 participants


Consider the following program:

type mymethod is method()->(int)

method m()->mymethod:
    &int x = new 1
    return &(->(*x))

Doesn't compile, as the type checker says that we return a function where a method is expected.

Change the type declaration to type mymethod is function()->(int), and then the compiler complains that dereference is not permitted in functions.

Related to #611


Chaning the return statement to return &(->(*x) + *(new 0)) makes it compile, because it is then detected as method. Looks like only new expressions make a lambda to a method right now.


Yeah, this is to do with the rather awkward may that methods are inferred for lambdas. Having an explicit syntax to indicate that a lambda is a function or method would be another solution.

But, I still think that the subtyping option makes sense.

@DavePearce DavePearce closed this in #638 Apr 25, 2016
@DavePearce DavePearce modified the milestone: v0.3.40 May 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment