Skip to content

Allow import language.experimental.captureChecking in the REPL #16304

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
wants to merge 2 commits into from

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Nov 8, 2022

Attempt to fix #16250 with @rjolly during the issue spree.

Two things currently seem to prevent import language.experimental.captureChecking to be used in the REPL.

1. needsCaptureChecking flag preservation across compilation units

The needsCaptureChecking is defined here:

var needsCaptureChecking: Boolean = false

And is set from handleGlobalLanguageImport:

ctx.compilationUnit.needsCaptureChecking = true

To preserve it, we tried calling handleGlobalLanguageImport in setImportInfo (4702968).

2. outermost syntax errror

Currently, a syntax error is emitted if the import is not at the top level:

if Feature.handleGlobalLanguageImport(prefix, imported) && !outermost then
syntaxError(i"this language import is only allowed at the toplevel", id.span)

Outermost is originally set here:

val isOutermost = in.currentRegion.isOutermost

We are not sure yet if and how we should special-case this flag so that it works with wrapper objects generated by the REPL.

@mbovel
Copy link
Member Author

mbovel commented Nov 3, 2024

Closing in favor of the new #21725.

@mbovel mbovel closed this Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REPL : pureFunctions and captureChecking fail with "language import only allowed at toplevel"
1 participant