Skip to content

-Yexplicit-nulls no longer allows eq and ne comparsion, needs better errors message #24139

@WojciechMazur

Description

@WojciechMazur

Based on the OpenCB failure in stg-tud/bismuth - build logs

Compiler version

Last good release: 3.8.0-RC1-bin-20250817-8c3f1a6-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250818-aaa39c5-NIGHTLY
Bisect points to aaa39c5 (seems unrelated)

Minimized code

//> using options -Yexplicit-nulls

trait Key[T]
trait Bucket[T]:
  def key: Key[T]
  
def Test = 
  val bucket: Option[Bucket[String]] = ???
  val key = bucket.fold[Key[String] | Null](null)(_.key)
  if (key ne null) then 
    println("not null")
        

Output

[error] ./test.scala:10:7
[error] expression does not take parameters
[error]   if (key ne null) then 
[error]       ^^^^^^^^^^^

Expectation

Should either compile or the error message should suggest using == / != operators

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions