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

Explicit declaration of function types can not handle tuple-valued return types #347

Closed
Bearmarshal opened this issue Mar 17, 2016 · 3 comments

Comments

@Bearmarshal
Copy link

All these examples fail due to an explicitly declared tuple-valued return type of fun:

class Foo {
  fun : int -> (int, int)
  ...
}
class Bar {
  def bar(fun : int -> (int, int)) : void {
    ();
  }
  ...
}
class Main {
  def main() : void {
    let fun = ( \ (x : int) -> (x, x+1)) : int -> (int, int);
    ();
  }
}

The third example, however, succeeds if you remove the explicit type declaration. This, however, is not an option in the first and second case.

@ghost
Copy link

ghost commented Mar 18, 2016

     arrow = do lhs <- parens (commaSep typ)
                     <|> do {ty <- nonArrow ; return [ty]}
                 reservedOp "->"
                 rhs <- nonArrow
                 return $ arrowType lhs rhs

rhs <- nonArrow should be rhs <- typ right? The current implementation also fails for functions returning maybes as well as functions returning functions.

@ghost ghost mentioned this issue Mar 18, 2016
@TobiasWrigstad TobiasWrigstad assigned ghost Mar 18, 2016
@supercooldave supercooldave mentioned this issue Apr 6, 2016
3 tasks
supercooldave pushed a commit that referenced this issue Apr 6, 2016
Fixes issue #347 where the parser would only allow nonArrow types in the right hand side of an arrow type.

Also makes the indentation in the type parser consistent with the rest of the project.
@Bearmarshal
Copy link
Author

While this is fixed for primitive types, see issue #364.

@TobiasWrigstad
Copy link
Contributor

Fixed

albertnetymk pushed a commit that referenced this issue Apr 23, 2016
* fix #347: lambda return types

* fixes inconsistent indentation in the type parser

* Adds pattern matching on function, method and stream heads.

* fixed remaining util functions

* major fixes and bug fix

* fixed capability bug on desugaring

* updated documentation with patterns in function defs

* Minor fixes

* Fixed error handling and messages

Known issue: Cannot match on negative numbers in function headers

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

No branches or pull requests

2 participants