scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.04k stars 318 forks source link

Bug: Insert Missing Cases For Type Union #6549

Open nguyenyou opened 4 days ago

nguyenyou commented 4 days ago

Describe the bug

I used pattern matching for a string literal type union and encountered a very interesting bug, the generated code by VSCode after I hit "insert missing cases" is:

type Color = "primary" | "secondary" | "danger" | "warning"

def getColor(color: Color) = color match
  case "primary" => "bg-red-200"
  case "secondary" => ???
  case "danger" => ???
  case "warning" => ???

https://github.com/scalameta/metals/assets/38455472/5d65d2b6-79df-4c7d-b5a3-67ef5f1dd8bd

cc @kasiaMarek

Expected behavior

No weird characters are generated along with the actually singleton string.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

1.3.2+15-8bebd63c-SNAPSHOT

Extra context or search terms

No response

tgodzik commented 4 days ago

Thanks for reporting! That's actually coming from the compiler, tough I have no idea how this would show up as I think those are color codes? We can strip them in Metals, but we should check if it's actually coming in the actionable diagnostic in the compiler, which was added in https://github.com/scala/scala3/pull/18314/files