errcatch doesn't catch a syntax error. e.g.
errcatch (parse_string (")abc"));
prints an error message but doesn't yield [] as expected. Probably what's going on is that errcatch catches some specific errors but doesn't catch whatever MREAD-SYNERR is throwing (namely whatever is thrown by THROW-MACSYMA-TOP).
I am struggeling with the same bug at the moment e.g. :
errcatch(parse_string("Heading="));
Does not give []
I just looked at this a bit.
errcatchneeds to catch throws toMACSYMA-QUITto catch the mentioned parser errors, as well as some other errors (e.g., from the Galois field functions in numth).It looks like
errcatchshould also catch throws toERRORSWas well. TheERRORSWvariable controls whether or not some errors just cause a throw toERRORSWinstead of the signaling of a Maxima error.ERRORSWis bound toTin various places in src and there are various catchers setup in src.ERRORSWis also bound toTwhile evaluatingerrcatchforms in the hyperint contrib package.Currently if something in an
errcatchthrows toERRORSWand nothing ever catches it, thenerrcatchwill "catch" this due to the eventual lisp error from a throw to a nonexistent tag (and it will also by default print the error report message about the nonexistent tag from lisp and store that message in Maxima'serrorvariable). If a catcher is setup outside theerrcatch, thenerrcatchwill not catch the error. (errcatchshould catch this just like it will catch throws toRAT-ERReven if something outside theerrcatchwould have caught it.)There are other tags that
errcatchcould catch, but I don't see any other particularly reasonable ones yet. I don't want to set up a bunch of catchers inerrcatch, but I'll still look a bit more.Anyway, I'll update
errcatchto catch these new "errcatch tags".In the cases where
errcatchcatches a throw toMACSYMA-QUITorERRORSW,errcatchhas no info on the error that occurred. In these cases I'll make sure some message is stored in Maxima'serrorvariable stating thaterrcatchcaught an error (soerrordoesn't have "No error." or some previous error message in it.)parse_stringalso gives very peculiar errors:Why on earth is
rse_string("++";part of the error?From glancing at
MREAD-SYNERRI'm guessing thatCOLUMNis going back too far in*PARSE-WINDOW*. I'll try to also look at that more closely soon too.The bug where
errcatchfailed to catch some errors has been fixed by commit [f11cab]. I just stuck withERRORSWandMACSYMA-QUITas I described before.Errors from things like
%i2and%i3were uncaught byerrcatchbefore. For something like%i4it was like I described in my previous comment aboutERRORSW.For the other issue that Stavros mentioned regarding error messages, I'll need to look into all of this more because there is another issue. I think my initial guess about
COLUMNwas correct, but when I started testing I managed to get a lisp error from a bogus comparison (without me changing anything). I don't feel like messing with that right now, but I've made note of these issues and I'll try to look into them further soonish.Related
Commit: [f11cab]
Kris, thanks for working on this problem. For the record, I worked on a similar problem some time ago, and what was able to figure out is in:
https://github.com/maxima-project-on-github/maxima-packages/tree/master/robert-dodier/catchable_syntax_error
You mentioned that
errordoesn't have a helpful error message afterwards -- I guess I was able to figure out how to put the parser error message intoerror. It is a minor point.Hi Robert. Thanks for the comment and the link. Sorry I didn't remember your previous work on that.
Yes, the way I went about this was focusing on
errcatchsince there were other errors that weren't being caught.My initial idea was to focus on
MREAD-SYNERRitself, which is what you did. I see that your newMREAD-SYNERRcallserror, which callsMERROR, and so theerrorvariable gets updated with the actual error message. (In my approach I also callMERRORto geterrorupdated, but I only have a generic error message since I call fromerrcatch.)I notice that you do not have stuff like line info in your error messages anymore (which you also mention in a comment). My original idea for changing
MREAD-SYNERRwas to basically build up a string with the existing info and pass that toMERRORso that theerrorvariable would be updated anderrcatchwould catch the error. I didn't think about that much and I didn't actually try that before moving on toerrcatchitself. I wonder if things like line info are missing from yours because you tried something like that and ran into problems.Last night I was able to look into the issue that Stavros mentioned and the lisp error I mentioned before.
I have fixes for both: one involving changing a binding in
PARSE-STRINGso that*PARSE-WINDOW*is updated appropriately inMREADand the other involves checking for the EOF value in when traversing*PARSE-WINDOW*(this EOF value can come from loading a Maxima file, for example). The lack of EOF checking was causing the bogus comparison I mentioned.After that I found another lisp error I need to investigate. I hope to have time to look at this more later this week.
I finally got to sit down and take care of these other issues. They've been fixed by commits [1584c5], [c5cadb] and [8ea190].
By the way, here was an trivial way to trigger a lisp error under clisp:
This is that other lisp error I mentioned a few days ago, and it's fixed by the last commit listed above.
Thanks for working on it, Kris!