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

Opportunity for better precedence in given declarations with experimental.modularity #20364

Open
propensive opened this issue May 8, 2024 · 0 comments
Labels
stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@propensive
Copy link
Contributor

propensive commented May 8, 2024

Compiler version

Latest main, 3393f7ea7704eb1dd553c96a805906821c61db5f.

Minimized example

I've found a couple of cases using the new "modularity" syntax where parentheses are required, but where the parser ought to be able to parse unambiguously without.

Assuming a typeclass definition such as,

trait Describable:
  type Self
  def describe(): String

We cannot write:

given 8 is Describable = () => "eight"

We must write,

given (8 is Describable) = () => "eight"

and likewise for String singleton literal types.

And with language.experimental.captureChecking, the parentheses are also required for:

given (using ord: Ordering[Int]^) => (Int is Describable^{ord}) = () => "integer"

This is just mild friction, though the error messages are not informative. Another related case where parentheses become necessary occurs in pattern matching (typically only in an inline context, because usually erasure obviates matching on the Self parameter):

An "old-style" typeclass could be matched with,

compiletime.summonFrom:
  case describable: Describable[T] => // ...

but the equivalent in "new style" must now be written,

compiletime.summonFrom:
  case describable: (T is Describable) => // ...
@propensive propensive added the stat:needs triage Every issue needs to have an "area" and "itype" label label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant