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

Improve import selector parsing #6019

Closed
som-snytt opened this issue Mar 4, 2019 · 4 comments
Closed

Improve import selector parsing #6019

som-snytt opened this issue Mar 4, 2019 · 4 comments

Comments

@som-snytt
Copy link
Contributor

som-snytt commented Mar 4, 2019

Scala 2 received upgraded parsing of import selectors, including handling underscore, at scala/scala#6218. There may be something to forward-port.

scala> import collection._ => `not a rename, just dross`                                   
1 |import collection._ => `not a rename, just dross`
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^
  |                       ';' expected, but identifier found

scala> import collection._ => ;

scala> 

Comparing Scala 2:

scala> import collection._ => `not a rename, just dross`
                           ^
       error: ';' expected but '=>' found.

The bad syntax was ignored completely until 2.13.

Edit: the Scala 2 change addresses some but not all issues around use of underscore, and the parsing improvement was just fall-out.

@smarter

This comment has been minimized.

@odersky
Copy link
Contributor

odersky commented Mar 18, 2019

scalac 's behavior is not backed by the language spec. I think if we want to change this it has to go through the SIP process, and I for one would vote against the change. No need to get more syntactic options for features that occur rarely anyway.

@odersky odersky closed this as completed Mar 18, 2019
@som-snytt
Copy link
Contributor Author

som-snytt commented Mar 18, 2019

The parser incorrectly accepts

scala> import collection._ => ;

Also worth mentioning that the linked scalac issue is per spec: backquoted underscore is an identifier, but unadorned underscore is a reserved word.

@som-snytt
Copy link
Contributor Author

This progressed, probably when export was added.

➜  dotty ./dotty-0.12.0/bin/dotr     
Starting dotty REPL...
scala> import collection._ => ;                                                                                      

scala>                                                                                                               
➜  dotty ./dotty-0.13.0/bin/dotr
Starting dotty REPL...
scala> import collection._ => ;                                                                                      

scala>                                                                                                               
➜  dotty ./dotty-0.14.0/bin/dotr
Starting dotty REPL...
scala> import collection._ => ;                                                                                      
1 |import collection._ => ;
  |                    ^^
  |                    end of statement expected

scala>

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

3 participants