Repository navigation
Get: go on reading the file after a syntax error, as in WMA - #1999
Merged
rocky merged 2 commits intoOct 16, 2026
Merged
Conversation
eval_Get returned at the first syntax error, so everything after it in the file was silently skipped. WMA documents: "Get continues attempting to read a file even after a syntax error has been detected." Report the error and continue with the next expression; stop only if the parser made no progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rocky
reviewed
Oct 16, 2026
| # As in WMA, Get reports a syntax error and goes on reading the file. | ||
| script_path = canonic_filename( | ||
| osp.normpath( | ||
| osp.join(osp.dirname(__file__), "..", "..", "data", "syntax-error-bug.m") |
Member
There was a problem hiding this comment.
I'd appreciate it if we could change the extension here to end in .wl. The problem with .m extensions is that Objective-C headers also have an .m extension. Using .wl at the end, though, is unambiguously Wolfram Alpha as far as I can tell.
Collaborator
Author
There was a problem hiding this comment.
Done in 1f544ac: the file is now test/data/syntax-error-bug.wl; nothing else changes. Most of the other files in test/data/ (script.m, input-bug.m, star-bug.m, …) are still .m. If you'd like, I can rename those in a separate PR.
Member
There was a problem hiding this comment.
Many thanks! Yes, I'd be grateful if you'd rename the others in a separate PR.
.m is also the extension of Objective-C sources; .wl is unambiguous. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
Gethits a syntax error, Mathics3 currently prints the message and then stops reading the file. Everything after the error is silently dropped. WMA does not do this. Its reference page says:A minimal example (
test/data/syntax-error-bug.m):Geton this file currently reports the bad character name and returnsNull, sogetSyntaxCis never set. With this PR it reports the error, goes on reading, and returns{1, getSyntaxB, 3}.In older packages, one bad line near the top therefore lost most of the file. For example, a single mistyped
\[...]name lost hundreds of definitions that came after it.The change is in
eval_Get. After aSyntaxError, the loop continues with the next statement. As a guard against looping forever, it still returnsNullif the parser consumed no input, i.e. the feeder's line number did not advance.The new test
test_get_continues_after_syntax_errorfails on master and passes here. It deliberately does not check the text of the syntax message, because that text comes from Mathics3-scanner.🤖 Generated with Claude Code