This repository has been archived by the owner. It is now read-only.

Annotate more errors with expected token #172

Merged
merged 1 commit into from Oct 14, 2016

Conversation

Projects
None yet
3 participants
@motiz88
Copy link
Contributor

motiz88 commented Oct 14, 2016

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 reimplement expect()) to construct an Unexpected 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 say expected FOO or BAR or BAZ where it makes sense.

Annotate more errors with expected token
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 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);

This comment has been minimized.

@danez

danez Oct 14, 2016

Member

Also a newline would be expected here I think.

This comment has been minimized.

@motiz88

motiz88 Oct 14, 2016

Author Contributor

Yeah. Do you have a preference as to the message here? Expected ; or newline?

@danez

This comment has been minimized.

Copy link
Member

danez commented Oct 14, 2016

@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.

@motiz88

This comment has been minimized.

Copy link
Contributor Author

motiz88 commented Oct 14, 2016

@danez Those are both assertions on messages that have changed in this PR. Not sure why one of them (transformation/errors/syntax) doesn't say so in the log and instead just throws the SyntaxError.

PR to make Babel tests pass with the new messages: babel/babel#4727

motiz88 added a commit to motiz88/babel that referenced this pull request Oct 14, 2016

@hzoo hzoo merged commit d3af158 into babel:master Oct 14, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

hzoo added a commit to babel/babel that referenced this pull request Oct 14, 2016

@motiz88 motiz88 referenced this pull request Oct 14, 2016

Merged

Fix up #172 #177

hzoo added a commit that referenced this pull request Oct 14, 2016

Fix up #172 (#177)
* Update two esprima tests to the new "expected TOKEN" messages

* Update dynamic-import to use "expected (" error message

chrisprice added a commit to chrisprice/babel that referenced this pull request Oct 18, 2016

kristofdegrave pushed a commit to kristofdegrave/babylon that referenced this pull request Oct 27, 2016

Annotate more errors with expected token (babel#172)
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.

kristofdegrave pushed a commit to kristofdegrave/babylon that referenced this pull request Oct 27, 2016

Fix up babel#172 (babel#177)
* Update two esprima tests to the new "expected TOKEN" messages

* Update dynamic-import to use "expected (" error message

panagosg7 added a commit to panagosg7/babel that referenced this pull request Jan 17, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.