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

Add a hint for using CC with REPL #22220

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3706,7 +3706,15 @@ object Parsers {
in.languageImportContext = in.languageImportContext.importContext(imp, NoSymbol)
for case ImportSelector(id @ Ident(imported), EmptyTree, _) <- selectors do
if Feature.handleGlobalLanguageImport(prefix, imported) && !outermost then
syntaxError(em"this language import is only allowed at the toplevel", id.span)
val location =
if ctx.mode.is(Mode.Interactive) then
"in the REPL"
else "at the toplevel"
val hint =
if ctx.mode.is(Mode.Interactive) then
f"\nTo use this language feature, include the flag `-language:$prefix.$imported` when starting the REPL"
else ""
syntaxError(em"this language import is only allowed $location$hint", id.span)
if allSourceVersionNames.contains(imported) && prefix.isEmpty then
if !outermost then
syntaxError(em"source version import is only allowed at the toplevel", id.span)
Expand Down
Loading