What does "The interpreter has gone wrong" mean?

Sometimes Matrix Brandy reports "The interpreter has gone wrong", more often than not "The interpreter has gone wrong at line 61". What does this really mean? What does 'line 61' refer to?

Comments

  • This will be a reference to a line in the source code, picked up by a GCC macro. The error should also identify which source component. The error won't actually be in that line, but that's the line of the statement reporting the error..!

    What were you doing to trip that error?
  • Soruk wrote: »
    What were you doing to trip that error?
    I can't remember exactly what I was doing on the most recent occasion, I've received that error more than once. I was more puzzled by what it actually means 'under the hood', compared with the more familiar errors like Syntax Error or Mistake. Does it indicate an unexpected 'fatal' error, like an access violation or similar? I know I should have checked the value of ERR, but I forgot.
  • A typical example of this is if execution has fallen off the end of all expected valued in a C switch() statement, which wouldn't be expected to happen.
  • Soruk wrote: »
    A typical example of this is if execution has fallen off the end of all expected valued in a C switch() statement, which wouldn't be expected to happen.
    Hmm, I still don't think I'm getting it. If the switch statement is making a decision based on something in the user's BASIC program, and what it sees wasn't 'expected' in that context, that's a Syntax Error isn't it?

    The message "the interpreter has gone wrong" implies to me that the interpreter is at fault, but on the occasions when I have received that error it will be my BASIC program which was 'at fault' for containing code not compliant with the language syntax.

    I suppose the fundamental reason for me not being able to grasp this is that none of my interpreters, right back to the Z80 version, have had anything similar. A mistake in the BASIC program is either detected (in which case it reports Syntax Error or similar) or it isn't detected (in which case, by definition, nothing is reported).

    I can't think of anywhere in my interpreters where this 'mistake of the third kind' could happen.
  • Another way to think about it is a "caught" crash in the interpreter. If the BASIC program is incorrect a proper error message should be raised.
  • Soruk wrote: »
    Another way to think about it is a "caught" crash in the interpreter. If the BASIC program is incorrect a proper error message should be raised.
    Ah, that's what I meant by "Does it indicate an unexpected 'fatal' error, like an access violation or similar?" above.

    In my interpreters I don't attempt to 'catch' any fatal errors, because Raymond Chen says it's a very bad thing to do - it's just risking later instability.

    Anyway, there is no mechanism in SDL2 to do that in a cross-platform fashion (I bet the code you use doesn't work in Android, iOS and Emscripten - if it does I'd be interested to see it).

    So the upshot of all this is that a simple syntax error in the BASIC code can trigger a 'fatal' (albeit caught) error? That's surprising, isn't it?
  • It shouldn't do, from what I have figured out it's Dave Daniels' attempt to go "Oops, that shouldn't have happened..." and try to give some indication where in the code it happened as a kind of a debugging statement.