jupyter-xeus/xeus-octave

Inconsistent error with octave interpreter

AntoinePrv opened this issue · 2 comments

Case 1

Input

*+3

Xeus-Octave behavior

Execution exception: parse error:

  syntax error

>>> *+3
    ^

ans = 3

ans get set to 3.

Octave behavior

error: parse error:

  syntax error

>>> *+3

Case 2

Input

[][1]

Xeus-Octave behavior

Execution exception: parse error:

  syntax error

>>> [][1]
      ^

Execution exception: parse error:

  syntax error

Octave behavior

error: parse error:

  syntax error

>>> [][1]
      ^

Ping @rapgenic do you think this loop could be the cause of the continuation after error? Not sure what it is looping over.
Would adding a break statements after exceptions are handled make sense?

} while (exit_status == 0);

Hi, I've had a quick look at that, even though I wrote that a long time ago, so I'm not sure I can help...

First of all that is copied almost verbatim from octave code (I believe https://github.com/gnu-octave/octave/blob/36bd93dd549b211a13f39aa5f788253e37bb3558/libinterp/parse-tree/pt-eval.cc#L639) if you have a look at that you can see that it's meant to be a line by line evaluation which probably is incorrect for a "cell" (It might be more interesting to look at this other function instead https://github.com/gnu-octave/octave/blob/36bd93dd549b211a13f39aa5f788253e37bb3558/libinterp/parse-tree/pt-eval.cc#L575 which does not even have a while loop, so it might not be that necessary).

I tried building a version with breaks and it seems to work, but it might actually be more reasonable to avoid the loop altogether.

Secondly, while looking at that I discovered another bug which you might want to have addressed, regarding to the parser: whenever there is an error the error message always reports that it occurred at line 1.

immagine