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

keyword return and consume do not play along well #835

Open
kikofernandez opened this issue Jun 30, 2017 · 2 comments
Open

keyword return and consume do not play along well #835

kikofernandez opened this issue Jun 30, 2017 · 2 comments
Labels

Comments

@kikofernandez
Copy link
Contributor

Given a linear reference:

  • if I return the linear reference without consuming it, the typechecker complains
  • if I return the linear reference and consume it, the typechecker complains
  • if I just consume the reference and have it as the last expression in the method, everything is good

The following example shows these cases:

linear class B
  var x: String = "hola"
end

active class Main
  def test(): B
    new B
  end

  def main(): B
    var b = this.test()
    -- return b  --complains
    -- return consume b -- complains
    consume b -- OK
  end
end
@kikofernandez
Copy link
Contributor Author

kikofernandez commented Jun 30, 2017

The following test does not work either:

linear class B
  var x: String = "hola"
end

active class Main
  def main(): Maybe[B]
    return Nothing
  end
end

@kikofernandez
Copy link
Contributor Author

the error message in the second example is:

"test.enc" (line 7, column 5)
Cannot capture expression 'return(Nothing)' of linear type 'Maybe[B]'
In expression: 
  return(Nothing)
In method 'main' of type 'Maybe[B]'
In class 'Main'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant