Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Allow Infix on enum #152

Open
bishabosha opened this issue Dec 4, 2020 · 2 comments
Open

Allow Infix on enum #152

bishabosha opened this issue Dec 4, 2020 · 2 comments

Comments

@bishabosha
Copy link
Member

Minimized code

example 1:

infix enum mul[T <: Int, U <: Int] {                                                                                                                       
  case Refl(r: compiletime.ops.int.*[T,U])
}

example 2:

enum Expr {
  infix case Add(l: Expr, r: Expr)
  case Lit(i: Int)
}

Output

example 1:

1 |infix enum mul[T <: Int, U <: Int] { 
  |           ^^^
  |           Only access modifiers are allowed on enum definitions

example 2:

2 |    infix case Add(l: Expr, r: Expr)
  |          ^^^^
  |          end of statement expected but 'case' found
2 |    infix case Add(l: Expr, r: Expr)
  |               ^^^
  |               ';' expected, but identifier found

Expectation

infix is allowed for a class definition:

example 1:

infix sealed trait mul[T <: Int, U <: Int]
object mul {
  final case class Refl[T <: Int, U <: Int](r: compiletime.ops.int.*[T,U]) extends (T mul U)
}
@odersky
Copy link

odersky commented Dec 4, 2020

That's an enhancement request, not a bug. infix behaves as is documented.

@bishabosha bishabosha changed the title Infix allowed on class but not enum Allow Infix on enum Dec 4, 2020
@odersky
Copy link

odersky commented Dec 26, 2020

I think it should be a feature request. Let's try to keep the issues here focussed on actionably items.

@odersky odersky closed this as completed Dec 26, 2020
@bishabosha bishabosha transferred this issue from scala/scala3 Dec 26, 2020
@bishabosha bishabosha reopened this Dec 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants