Skip to content

Inconsistent warning behaviour on initialisation: warning for class but not singelton object, AND difficult to find docs about warnings #24106

@bjornregnell

Description

@bjornregnell

Compiler version

Scala 3.7.3

Minimized code

//> using scala 3.7.3
//> using options -Wall

object NoWarningProvided:
  val a = b
  val b = 42

class WarningIsProvided:
  val a = b
  val b = 42

Output

$ scala compile .
Compiling project (Scala 3.7.3, JVM (21))
[warn] ./bug.scala:10:7
[warn] Access non-initialized value b. Calling trace:
[warn] ├── class WarningIsProvided:	[ bug.scala:8 ]
[warn]    ^
[warn] └── val a = b	[ bug.scala:9 ]
[warn]             ^
[warn]   val b = 42
[warn]       ^
Compiled project (Scala 3.7.3, JVM (21))

Expectation

Same warning also for object NoWarningProvided

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions