Skip to content

Star * infix type fails compilation #1961

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

Closed
soronpo opened this issue Feb 9, 2017 · 10 comments
Closed

Star * infix type fails compilation #1961

soronpo opened this issue Feb 9, 2017 · 10 comments

Comments

@soronpo
Copy link
Contributor

soronpo commented Feb 9, 2017

object InfixType {
  trait *[N1, N2]
  type Result = Int * Int
}

Gives

[error]   |  type Result = Int * Int
[error]   |                    ^
[error]   |                    ';' expected but identifier found
@smarter
Copy link
Member

smarter commented Feb 9, 2017

Backquoting doesn't help, same error when writing Int `*` Int instead

@smarter
Copy link
Member

smarter commented Feb 9, 2017

@som-snytt on Gitter mentioned that this was also the case before 2.11, then it got fixed and the spec updated: https://issues.scala-lang.org/browse/SI-8325

@odersky
Copy link
Contributor

odersky commented Feb 22, 2017

I am not sure this is a good fix. The problem is that it clashes with postfix * in varargs parameters. This would not be a problem if postfix `*' was a real postfix type op. But it isn't. Types don't have postfix ops at all. So I am not really sure how to fix this without major contortions in the parser. I would rather backout of the spec change here.

@smarter
Copy link
Member

smarter commented Feb 22, 2017

The parser change in scalac doesn't seem too bad: https://github.com/scala/scala/pull/3576/files

@odersky
Copy link
Contributor

odersky commented Feb 22, 2017

It requires lookahead, which is a big deal because it widens the Scanner/Parser interface. Dotty's parser does not need lookahead.

@smarter
Copy link
Member

smarter commented Feb 22, 2017

IIRC, lookahead is also needed to get the inline keyword to work under -language:Scala2: #1492 (comment) which is something I wanted to implement.

@odersky
Copy link
Contributor

odersky commented Feb 22, 2017

Right. But I think it is one thing to require lookahead for a backwards compatibility hack, but another to require the official grammar to support it.

@jozanek
Copy link

jozanek commented Oct 16, 2017

This is probably resolved.

@soronpo
Copy link
Contributor Author

soronpo commented Oct 16, 2017

This is probably resolved.

In which version? I tried it on Scastie now and still produces the same compilation error.

@allanrenucci
Copy link
Contributor

I can still reproduce on mater

odersky added a commit that referenced this issue Jan 25, 2018
Fix #1961: Allow `*` as an infix operator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants