You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error positions are currently reported by attaching to a token, but this doesn't work at the end of the file.
For example, on a file containing just the word val, the parser attempts to parse a pattern immediately after the val, but since this is the last token of the file, it crashes.
Problem
Error positions are currently reported by attaching to a token, but this doesn't work at the end of the file.
For example, on a file containing just the word
val
, the parser attempts to parse a pattern immediately after theval
, but since this is the last token of the file, it crashes.This particular example crashes at the call
tok i
below, because it is an out-of-bounds access.https://github.com/shwestrick/parse-sml/blob/6e61e1e431ca2aa8f4ddf6f3a47a9d1f8a0b5851/parse/ParsePat.sml#L106-L111
But this problem is more pervasive: many of the errors throughout the parser are similarly designed.
Suggested Solution
Introduce a new error function which similar to previous but now is aware of the token stream, e.g.
Then all of the error sites need to be replaced (should be a nice little bit of zen refactoring 💆🏻♂️)
The text was updated successfully, but these errors were encountered: