Skip to content

Opaque type aliases not working as top level statements in repl #12748

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
Kordyjan opened this issue Jun 8, 2021 · 2 comments
Closed

Opaque type aliases not working as top level statements in repl #12748

Kordyjan opened this issue Jun 8, 2021 · 2 comments

Comments

@Kordyjan
Copy link
Contributor

Kordyjan commented Jun 8, 2021

Trying to define opaque type as a top-level statement in the repl is causing a parser error. It is also not working if opaque type definition is loaded from the file that is normally passing the compilation, using :l. Wrapping opaque type in object solves the problem.

Compiler version

master branch as of commit d7d4a9f

Minimized code

Any opaque type definition for example:

opaque type L = Int

Output

1 |opaque type L = Int
  |^^^^^^
  |Illegal start of statement: this modifier is not allowed here

Expectation

Opaque type is defined without errors

@Kordyjan Kordyjan changed the title Opaque types not working as top level statements in repl Opaque type aliases not working as top level statements in repl Jun 8, 2021
@tgodzik
Copy link
Contributor

tgodzik commented Jun 8, 2021

This looks like an issue in the Parsers:

https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/parsing/Parsers.scala#L3829

Seems that somehow isDefIntro(modifierTokens) is false despite there being an explicit check for soft modifiers. Does the REPL wrap the code somehow, that might be causing this issue?

@bishabosha
Copy link
Member

duplicate of #9879

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