Skip to content

Unclear error message with mutually recursive methods with inferred return types #2001

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

Closed
smarter opened this issue Feb 19, 2017 · 0 comments

Comments

@smarter
Copy link
Member

smarter commented Feb 19, 2017

class A {
  def odd(x: Int) = if (x == 0) false else !even(x-1)
  def even(x: Int) = if (x == 0) true else !odd(x-1)
}

dotty:

3 |  def even(x: Int) = if (x == 0) true else !odd(x-1)
  |                                            ^^^
  |                                     cyclic reference involving method odd

Contrast with scalac:

mutrec.scala:3: error: recursive method odd needs result type
  def even(x: Int) = if (x == 0) true else !odd(x-1)
                                            ^
odersky referenced this issue Feb 24, 2017
Better error messages for missing type of recursive definitions
Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Jul 1, 2018
XXX But that's maybe a bad idea, test on mutual recursion (scala#2001)!
Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Jul 5, 2018
XXX But that's maybe a bad idea, test on mutual recursion (scala#2001)!
Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Jul 7, 2018
XXX But that's maybe a bad idea, test on mutual recursion (scala#2001)!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant