8000 Unnecessary "recursive value somevar needs type" · Issue #10811 · scala/bug · GitHub
[go: up one dir, main page]

Skip to content
Unnecessary "recursive value somevar needs type" #10811
@tanin47

Description

@tanin47

I'm using Scala 2.12.4.

def test(data: Int): Int = { data + 2 }

def main(): Unit = {
  val result = test(data = 3)
  val data = "some string" + result
}

The above fails the compilation with:

[error] /somepathwithline: recursive value result needs type
[error]     val data = "some string" + result
[error]                                ^
[error] one error found
[error] (Test / compileIncremental) Compilation failed

But the belows work fine.

def test(data: Int): Int = { data + 2 }

def main(): Unit = {
  val result = test(3)  // Please notice that `data =` is removed.
  val data = "some string" + result
}
def test(data: Int): Int = { data + 2 }

def main(): Unit = {
  val result = test(data = 3) 
  val otherName = "some string" + result  // Please notice that this variable isn't `data`
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0