Skip to content

val pattern match extraction does not understand actual type (with or without type ascription.) #20334

Open
@megri

Description

@megri

Compiler version

3.4.1

Minimized code

val Array(1: Byte) = Array[Byte](1)

https://scastie.scala-lang.org/jOpc8BDCQ7ufoAGjiycSRg 😏

Output

(Warning)

pattern's type (1 : Int) does not match the right hand side expression's type Byte […]

Expectation

I think this is a bug? I expect the lefthand 1 in val Array(1) = Array[Byte](1) to be inferred as Byte, but even with the type ascription the code generates a warning.

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