4

Bug introduced in 9.0 and fixed in 9.0.1


When considering this question about re-formatting Cell (also this one), I encountered an issue which confuses me. I'll let the code itself speak:

Consider the following simple Cell expression, which contains a comment line:

cellexpr = 
  Cell[BoxData[{RowBox[{RowBox[{"a", ";"}], "\[IndentingNewLine]", 
       RowBox[{"(*", RowBox[{"b", ";"}], "*)"}]}], 
     "\[IndentingNewLine]", "c"}], "Input"];

Write it to a Notebook:

testnb = NotebookCreate[];
NotebookWrite[testnb, cellexpr];

It looks like the following, which is what one would expect:

enter image description here

Now read the Cell expression back from testnb:

SelectionMove[testnb, Before, Notebook];
SelectionMove[testnb, Next, Cell];
NotebookRead[testnb]

Mathematica graphics

Note the first RowBox, it has a structure as RowBox[ item1, item2, ...], which is ill-posed since the first argument to RowBox must be a list. And the obtained Cell expression is therefor ill-posed, which can be seen by CellPrint-ing it:

enter image description here

I noticed that if the comment-line part is removed (e.g. by deleting "(*" and "*)" in cellexpr), everything works fine. And for the example in this question, the second comment is correctly obtained:

Mathematica graphics

My question:

Did I miss something? Or is this a bug?

My system: Mathematica 9.0.0.0 on Windows 7 32-bit

Silvia
  • 27,556
  • 3
  • 84
  • 164
  • This may have been fixed in 9.0.1. Please take a look at what I got with 9.0.1 on OS X: http://i.stack.imgur.com/8J6Oy.png – Szabolcs Feb 25 '13 at 19:13
  • @Szabolcs Thanks for the information! Now I begin to wonder when and why this wired bug.. – Silvia Feb 25 '13 at 19:19
  • This is very similar to a bug I encountered with Mathematica version 5 on windowsXP. The problem was : when I had a comment at the end of a cell, the cell became sometimes corrupted. A look inside the cell with ctrl-shift-E reveals a Row without List inside. – andre314 Feb 25 '13 at 21:43
  • (follow the last comment) Maybe this problem has something to do with the fact there are two different characters * (see doc or ask details). These characters are very similar, but I saw at screen that the * in the (* was not the same as in *) (depending on system?) – andre314 Feb 25 '13 at 21:46
  • @andre Hmm.. Interesting.. I never noticed there are two kinds of stars.. – Silvia Feb 26 '13 at 05:12
  • 4
    It was a bug, newly introduced to 9.0.0, and subsequently fixed in 9.0.1. The same problem led to the oft-reported corruption of certain cells when you tired to merge them. – John Fultz Feb 27 '13 at 10:46
  • @JohnFultz Thank you! For fulfilling my curiosity! :D – Silvia Mar 01 '13 at 06:44

1 Answers1

2

According to John Fultz's comment, this was a bug:

It was a bug, newly introduced to 9.0.0, and subsequently fixed in 9.0.1. The same problem led to the oft-reported corruption of certain cells when you tried to merge them.

Silvia
  • 27,556
  • 3
  • 84
  • 164