Build the ability to format errors #1796
Merged
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.
Previously, we only supported error messages that were constant strings. This works for the most part, but there are some times where we want to include some part of the source in the error message to make it better.
For example, instead of "Token is reserved" it's better to write "_1 is reserved".
To do this, we now support allocating error messages at runtime that are built around format strings.
I don't actually think this should be the real solution here. Ideally we would provide the ability for these fields to be described so that we could template out some nice Ruby syntax error classes. But for now, this gets us closer to passing Ruby spec so I'd like to build this intermediate step.
cc @enebo this should allow us to start fixing some specific error message assertions. Now that we have this, would you be able to open an issue with the error messages that are not lining up?