Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message when an enum extends AnyVal #21944

Open
hamzaremmal opened this issue Nov 13, 2024 · 0 comments
Open

Better error message when an enum extends AnyVal #21944

hamzaremmal opened this issue Nov 13, 2024 · 0 comments
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala area:enums area:reporting Error reporting including formatting, implicit suggestions, etc area:value-classes Issues tied to value classes. better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement Spree Suitable for a future Spree

Comments

@hamzaremmal
Copy link
Member

Compiler version

bed0e86

Minimized example

enum Orientation extends AnyVal:
    case North, South, East, West

Output Error/Warning message

-- [E074] Syntax Error: t.scala:2:5 --------------------------------------------
2 |enum Orientation extends AnyVal:
  |     ^
  |     Value classes may not be abstract
-- [E093] Syntax Error: t.scala:3:29 -------------------------------------------
3 |    case North, South, East, West
  |                             ^
  |               anonymous class {...} cannot extend final class Orientation
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | A class marked with the final keyword cannot be extended
   -----------------------------------------------------------------------------

Why this Error/Warning was not helpful

The message leaks implementation details about desugaring...

Suggested improvement

A message saying that enums cannot extend AnyVal is better here

@hamzaremmal hamzaremmal added itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc area:desugar Desugaring happens after parsing but before typing, see desugar.scala area:enums Spree Suitable for a future Spree better-errors Issues concerned with improving confusing/unhelpful diagnostic messages area:value-classes Issues tied to value classes. labels Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala area:enums area:reporting Error reporting including formatting, implicit suggestions, etc area:value-classes Issues tied to value classes. better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement Spree Suitable for a future Spree
Projects
None yet
Development

No branches or pull requests

1 participant