question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REPL not sufficiently isolated from class artifacts in current directory

See original GitHub issue

Compiler version

3.0.0

Minimized code

➜  snips scala oq.scala
2
0
➜  snips
➜  snips scalac -version
Scala compiler version 3.0.0 -- Copyright 2002-2021, LAMP/EPFL
➜  snips rm *.class *.tasty
➜  snips scala oq.scala
2
2

Output

This should never happen:

➜  snips vi hi.scala
➜  snips cat hi.scala

@main def test() = println("hello, world")
➜  snips scala hi.scala
hello, world
➜  snips scalac hi.scala
➜  snips vi hi.scala
➜  snips scala hi.scala
hello, world
➜  snips cat hi.scala

@main def test() = println("goodbye, cruel world")
➜  snips

Expectation

Running a script or interactive REPL actually runs the source text.

This is a follow-up to https://github.com/lampepfl/dotty/issues/7635 which was improperly closed.

Noticed again at https://gitter.im/scala/scala?at=60a9b889850bfa2d3bdaae09

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
SethTisuecommented, Dec 2, 2021

PR: #14021 (yes, that hypothesis was the way forward)

3reactions
SethTisuecommented, Nov 23, 2021

The King James Bible (1611) also spells it “subtil”. Most famously in Genesis: “the serpent was more subtil than any beast of the field…”

Dale and I spent about two hours looking at this today and we learned some things but don’t really have a solution in sight yet. But both of us want to keep working on it, both for the importance of the bug itself, and because it’s good learning and good saw-sharpening.

Some of the code we were studying:

  • ReplCompiler#newRun is where each new thing entered in the REPL gets access to the bindings established earlier in the session; a fold repeatedly calls importPreviousRun, which does ctx.fresh and .withRootImports(RootRef(() => requiredModuleRef(path)) :: Nil) where path is successively repl.rs$line$1, repl.rs$line$2, and so on. (The repl. part was added by Tom in #12607.)

  • References to names are resolved in Typer by findRef which calls findRefRecur which calls checkNewOrShadowed, which seems relevant and perhaps if we studied it (and/or added logging and/or stepped through it in a debugger) we’d have an aha moment.

At the broadest level, we still don’t know:

  • Does something go wrong at the time the directory in the file system is seen and a package symbol created for it?
  • Or does something first go wrong at the point when the def or val is entered?
  • Or is all of that working as intended, and the bug occurs only when you attempt to reference the def or val?

We sort of circled around between these three possibilities, dipping shallowly into each one, without committing yet to truly proving or disproving a particular one.

Dale has a WIP branch with some added logging (but those logs have yet to produce a smoking gun).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expired artifacts still taking disk space (#346261) - GitLab.org
No artifact should ever be stored for more than a week. Build artifacts seem to expire correctly, but sometimes they are not removed...
Read more >
Building applications with Maven - Quarkus
The project is generated in a directory named after the passed artifactId. ... Adding extension io.quarkus:quarkus-agroal ❌ Cannot find a dependency ...
Read more >
The Bazel Code Base
The exec root, a directory that contains symlinks to all the source code for the current build. It's located at $OUTPUT_BASE/execroot .
Read more >
Working with artifacts | Freddys blog
In the US folder you will find a manifest.json + all the things that ... If the container was started using a docker...
Read more >
Learning the Basics - Gradle User Manual
Gradle provides sufficient tooling to visualize, navigate and analyze the ... flat directory repositories cannot be used to override artifacts with real ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found