Skip to content

Commit ecccfc9

Browse files
committed
Add hint when found cc language import in repl
1 parent c61897d commit ecccfc9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3706,7 +3706,11 @@ object Parsers {
37063706
in.languageImportContext = in.languageImportContext.importContext(imp, NoSymbol)
37073707
for case ImportSelector(id @ Ident(imported), EmptyTree, _) <- selectors do
37083708
if Feature.handleGlobalLanguageImport(prefix, imported) && !outermost then
3709-
syntaxError(em"this language import is only allowed at the toplevel", id.span)
3709+
val hint =
3710+
if ctx.mode.is(Mode.Interactive) then
3711+
f"\nTo use this language feature, include the flag `-language:$prefix.$imported` when starting the REPL"
3712+
else ""
3713+
syntaxError(em"this language import is only allowed at the toplevel$hint", id.span)
37103714
if allSourceVersionNames.contains(imported) && prefix.isEmpty then
37113715
if !outermost then
37123716
syntaxError(em"source version import is only allowed at the toplevel", id.span)

0 commit comments

Comments
 (0)