Skip to content

Commit

Permalink
Refine the hint
Browse files Browse the repository at this point in the history
  • Loading branch information
Linyxus committed Dec 16, 2024
1 parent ecccfc9 commit 958371c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3706,11 +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
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 at the toplevel$hint", id.span)
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

0 comments on commit 958371c

Please sign in to comment.