Skip to content

Conversation

@saschanaz
Copy link
Member

@saschanaz saschanaz commented May 25, 2018

This PR introduces probe() function which checks whether the next unconsumed token has the target type.

Currently checking excessive tokens requires using consume():

if (consume("?")) error("Can't nullable more than once");

Our error() method assumes that the error is from the first unconsumed token so it potentially throws with incorrect line number. The error message from the following example says it's from line 3 because the first unconsumed token is there.

interface X {
  attribute object?? // error is from line 2, but webidl2.js throws with line 3
    attributeName;
};

probe() will fix this by checking the next token without consuming it:

if (probe("?")) error("Can't nullable more than once");

Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@saschanaz saschanaz merged commit f116f14 into develop May 25, 2018
@saschanaz saschanaz deleted the probe branch May 25, 2018 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants