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

Deprecate object $ to avoid unsoundess #1395

Open
nicolasstucki opened this issue Feb 16, 2024 · 0 comments
Open

Deprecate object $ to avoid unsoundess #1395

nicolasstucki opened this issue Feb 16, 2024 · 0 comments

Comments

@nicolasstucki
Copy link

nicolasstucki commented Feb 16, 2024

The Scala spec states that identifiers that contain the $ characters are reserved for compiler-generated names. Any other use has undefined behavior.

One of these (object $) caused a bug in scala/scala3#19702. We are trying to add an ad-hoc patch to support these broken classes from Ammonite. But this patch cannot be guaranteed to work forever and there is no guarantee that these definitions do not introduce more issues (that may not be by the compiler).

The following names can cause undefined behavior: object $, package $file, package $exec, package $ivy, package $url, package $stub, package $cp, package $plugin, package $repo. These are defined in https://github.com/com-lihaoyi/Ammonite/blob/main/amm/interp/api/src/main/scala/ammonite/Stubs.scala. There might be more problematic names.

The only possible solution is to deprecate these objects and migrate to some sound naming scheme.

lihaoyi pushed a commit that referenced this issue Jun 10, 2024
Added 3.4.2 to targets in a fairly straightforward, formulaic fashion.
3.4.0 and 3.4.1, for good reason, fail to parse `$` as a class file, but
a [temporary ad-hoc workaround was added in
3.4.2](scala/scala3#19705), so this needn't
block 3.4 support for now. Reliance on `object $` still needs to be
[fixed in
Ammonite](#1395).

Several internals changes required fixes also; I used the most obvious
solution (e.g. if Y extends X and Y is now private, use X instead), but
someone who knows more might want to read it over.

Tests pass on my machine for 3.3 and 3.4.2 (under Java 21).

If accepted, this patch would supersede
#1394
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

No branches or pull requests

1 participant