[clang] Issue143668 (PR #149396)

David Spickett via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 18 01:46:09 PDT 2025


================
@@ -158,12 +158,12 @@ TEST_F(InterpreterTest, UndoCommand) {
 
   // Fail to undo.
   auto Err1 = Interp->Undo();
-  EXPECT_EQ("Operation failed. Too many undos",
+  EXPECT_EQ("Operation failed. No input left to undo",
             llvm::toString(std::move(Err1)));
   auto Err2 = Interp->Parse("int foo = 42;");
   EXPECT_TRUE(!!Err2);
   auto Err3 = Interp->Undo(2);
-  EXPECT_EQ("Operation failed. Too many undos",
+  EXPECT_EQ("Operation failed. No input left to undo",
----------------
DavidSpickett wrote:

The complication here is that although the clang-repl `%undo` only undoes one input, the internal method can actually undo more than that. This test for example is trying to undo 2 things.

So the code needs to be a bit more intelligent. You have two situations:
* You have nothing left to undo.
* You have some things left to undo but *want* to undo more than that.

In both cases you error because you don't want to partially undo something, but the message should be specific. In the same order as above, I suggest:
* "No input left to undo"
* "Want to undo X inputs, only have Y" (with the message formatted with the correct numbers)

For formatting the error, we have some utilities to do that, I will find those for you.

Side note: "inputs" might not be the right noun, but stick with it for now and we can ask a clang-repl maintainer whether it's ok.

https://github.com/llvm/llvm-project/pull/149396


More information about the cfe-commits mailing list