Conversation
| } | ||
|
|
||
| $str = $this->raw; | ||
| $str = maxima_parser_utils::remove_comments($this->raw); |
There was a problem hiding this comment.
I'll make my own branch...
This is a problem. If you go and modify the source code before parsing, then the parser-generated position data will be off, and any error messages given will reference the wrong lines/columns, which would be a shame if we ever get a line-numbered code editor.
So instead of trimming and removing extra stuff, we should always just give the raw input to the parser. Well, you can always just do if(trim($str)==='') first to avoid having to init the parser for truly empty stuff, but you should not give the parser the trimmed content.
Even if the old comment remover might be faster and more efficient than the full parsing logic, the price would be the loss of position data, and we do not want to pay that.
If the new parser does not already parse "empty" or "just comments" contents without trouble, I'll make it do so, after all, the Rust version of it does do so.
There was a problem hiding this comment.
OK, thanks @aharjula I didn't really appreciate we need the position data later. That makes perfect sense. Yes, the test case here fails without some changes.
7b70035#diff-13d288001e398079c72696b47904ebfc96bb7dbe04b9aba0a3d0af367609925bR450
Fix to issue #1661.