Fix all REPL tests when production behavior is enabled - #25449
Conversation
4cb9152 to
1232da6
Compare
| | Cannot extend sealed trait CanEqual in a different source file | ||
| | | ||
| | longer explanation available when compiling with `-explain` | ||
| 2 warnings found |
There was a problem hiding this comment.
see the change below for why this happens but we don't print the warnings
There was a problem hiding this comment.
if it's about the stale symbol, I believe it should be fixed.
|
@hamzaremmal I'm interested in your thoughts on the 2nd commit. |
1232da6 to
bd12473
Compare
|
@hamzaremmal I've removed the 2nd commit, will probably reintroduce it in a later PR simplifying Vulpix in general, but I want to get the fixes to REPL tests in first |
For the record, we discussed it over Slack. |
In this case, I think your second commit had some merits. It added the |
|
The com.lihaoyi additions in #25444 were merged so I'm not sure I understand what you mean |
|
Right, sorry sorry. I lost track of what was done where. Let me check again the full context and I'll approve it if it all seems ok. |
| // We run the repl with `-Ydebug` to not use the fallback if there's a class load exception so we can notice these, | ||
| // but as a consequence we get debug messages; ignore the stale symbol one, whose contents include symbol IDs | ||
| // that depend on the exact compiler. | ||
| (optsLine :: buf.toList).filter(nonBlank).filter(!_.startsWith("stale symbol;")) |
There was a problem hiding this comment.
Mmmh, this feels like a hack, why remove an error that was effectively produced? We should either fix it if it was not supposed to be produced or keep it, but hiding it is not a good idea in my opinion.
There was a problem hiding this comment.
yeah, it's preexisting, it was just hidden before because we didn't run with -Ydebug. I'm not sure if it's fixable since we are, by design, creating a symbol with the same name twice, so isn't it normal that we end up with funny things?
There was a problem hiding this comment.
I don't think so. We might create the same symbol twice but during different run of the compiler, right?
Anyways, it's either we can do it then we should not have a stale symbol because the compiler knows how to handle it (it's part of it's business logic: "we can redefine symbols in the same REPL session") or we cannot do it then we should have a proper error saying "you cannot redefine this symbol during the same REPL session". This feels like it's in the middle of both possibilities; allowing you to redefine but at the same time the compiler is not very happy.
There was a problem hiding this comment.
yeah that's true, I'll be less lazy and try to actually fix it
bd12473 to
11a7bdc
Compare
|
@hamzaremmal Fixed, at some cost to my sanity. Turns out we were not propagating the new Also I deleted There's plenty more that could be cleaned up in the REPL, or for starters in the compiler (why are we hardcoding behavior for the REPL in the compiler??), but tests passing will do for now. |
| 1 error found | ||
| scala> while ((( foo ))) {} | ||
| -- [E006] Not Found Error: ----------------------------------------------------- | ||
| -- [E007] Type Mismatch Error: ------------------------------------------------- |
There was a problem hiding this comment.
we define it in the previous command...
I very much understand what you are saying ð
The REPL was until recently shipped in the same artifact as the compiler. We have just recently split it and it still needs A LOT of work to fully split the business logic. |
|
tbh the repl should be a good use case to "validate" the compiler API... if you can't easily implement a REPL, the compiler API needs work :) |
Agreed! |
hamzaremmal
left a comment
There was a problem hiding this comment.
LGTM, I just have a question I would like to know the answer to before approving.
| 1 error found | ||
| scala> while ((( foo ))) {} | ||
| -- [E006] Not Found Error: ----------------------------------------------------- | ||
| -- [E007] Type Mismatch Error: ------------------------------------------------- |
| 1 error found | ||
| scala> ((1, 2): Foo3.T[Int][Int][Int]): Foo3.T[Any][Int][Int] | ||
| val res2: Foo3.T[Any][Int][Int] = (1, 2) | ||
| val res3: Foo3.T[Any][Int][Int] = (1, 2) |
There was a problem hiding this comment.
So the basis of the fix is propagating the new state which makes indices increment even on errors.
As I see it, it's a fix but not the root cause probably. The context (the compiler's) and ofc the name table is still polluted. My question now is: what happens if we refer to res2 (a not found??)?
There was a problem hiding this comment.
it prints the error itself, which is kind of interesting:
scala> 42 + java.lang.Integer.TYPE
-- [E134] Type Error: ----------------------------------------------------------
1 |42 + java.lang.Integer.TYPE
|^^^^
|None of the overloaded alternatives of method + in class Int with types
| (x: Double): Double
| (x: Float): Float
| (x: Long): Long
| (x: Int): Int
| (x: Char): Int
| (x: Short): Int
| (x: Byte): Int
| (x: String): String
|match arguments ((Integer.TYPE : Class[Integer]))
1 error found
scala> 44
val res3: Int = 44
scala> res2
-- [E134] Type Error: ----------------------------------------------------------
1 |res2
|^^^^
|None of the overloaded alternatives of method + in class Int with types
| (x: Double): Double
| (x: Float): Float
| (x: Long): Long
| (x: Int): Int
| (x: Char): Int
| (x: Short): Int
| (x: Byte): Int
| (x: String): String
|match arguments ((Integer.TYPE : Class[Integer]))
1 error found
There was a problem hiding this comment.
(I wouldn't enshrine this into a test though, I don't think anyone should rely on this... for now at least)
There was a problem hiding this comment.
Mmmh, so this is not what we want to have obviously but the proposed fix brings it closer to what we would like to have (at least the test suite behaves correctly). I'm inclined to approve this but only if we dig further to check how we can rollback the changes in the context (compiler's Context).
Now, I find this funny because what would happen if we define a value class, say class Foo and add an expression that is broken afterwards (in the same cycle). Can we still use that same class in the next run of the REPL? Would it also show the error or do we just have something that is half working (Foo works and resX shows the error)?
There was a problem hiding this comment.
these are good question and I encourage you to create an issue for them, but let's please solve one problem at a time so we don't keep PRs open forever :-)
There was a problem hiding this comment.
these are good question and I encourage you to create an issue for them, but let's please solve one problem at a time so we don't keep PRs open forever :-)
We are not, I just want to understand what I'm approving.
I'm inclined to approve this but only if we dig further to check how we can rollback the changes in the context (compiler's Context).
I didn't mean here to say to do it right now, as long as we have an issue that highlights all of these problems, I'll approve the PR since it brings it closer to what we want.
There was a problem hiding this comment.
@hamzaremmal ping on clicking approve? ð
There was a problem hiding this comment.
I thought you will create the issue first.
| 1 error found | ||
| scala> buf ++= xs | ||
| val res0: mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) | ||
| val res1: mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) |
There was a problem hiding this comment.
I imagine all of those will be the same comment I made above.
Depends on #25444Fixes #25445
How much have your relied on LLM-based tools in this contribution?
not
How was the solution tested?
existing tests