-
-
Notifications
You must be signed in to change notification settings - Fork 258
Annotate more errors with expected token #172
Conversation
Expanding on babel#150, this allows `unexpected()` to accept the expected token type instead of a message string. This overload is then used in a couple more places (that independently implement a logic similar to `expect()`'s) to construct an `Unexpected token, expected FOO` message.
@@ -67,18 +67,22 @@ pp.isLineTerminator = function () { | |||
// pretend that there is a semicolon at this position. | |||
|
|||
pp.semicolon = function () { | |||
if (!this.isLineTerminator()) this.unexpected(); | |||
if (!this.isLineTerminator()) this.unexpected(null, tt.semi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a newline would be expected here I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Do you have a preference as to the message here? Expected ; or newline
?
@motiz88 Can you have a look and see why the babel tests now fail with this PR? One sems fine, but have no idea about the other failure. |
@danez Those are both assertions on messages that have changed in this PR. Not sure why one of them ( PR to make Babel tests pass with the new messages: babel/babel#4727 |
Expanding on babel#150, this allows `unexpected()` to accept the expected token type instead of a message string. This overload is then used in a couple more places (that independently implement a logic similar to `expect()`'s) to construct an `Unexpected token, expected FOO` message.
Expanding on #150, this allows
unexpected()
to accept the expected token type instead of a message string. This overload is then used in a couple more places (that essentially reimplementexpect()
) to construct anUnexpected token, expected FOO
message.I can imagine a future enhancement to
unexpected()
in which it would similarly take an array of token types; then we could sayexpected FOO or BAR or BAZ
where it makes sense.