-
Notifications
You must be signed in to change notification settings - Fork 5
support this
in tilde call expressions
#21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/parser/expression.js
Outdated
// allow Identifier or MemberExpression, but not calls | ||
node.right = this.parseSubscripts(this.parseIdentifier(), this.state.start, this.state.startLoc, true); | ||
let right; | ||
if (this.state.value === 'this') { |
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.
I think you probably want to check for this.state.type === tt._this
(explicitly check for the presence of a this
token) instead of looking at `state.value
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 this can probably be rewritten as
if (this.match(tt._this) {
right = this.parseExprAtom();
} ...
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.
For that matter, a ternary is probably appropriate
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.
Nice, I'm not too familiar with all the helpers yet. And especially since that's simpler the ternary works just fine.
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.
Nice, this is looking great!
} else if (this.hasPlugin("lightscript") && !noCalls && this.eat(tt.tilde)) { | ||
const node = this.startNodeAt(startPos, startLoc); | ||
node.left = base; | ||
// allow Identifier or MemberExpression, but not calls |
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.
Let's retain this comment (below the line you inserted)
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.
Restored, but above the newly added line and also calling out that this
is allowed.
@@ -0,0 +1 @@ | |||
a~this.method() No newline at end of file |
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.
Let's add a newline at eof
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.
Done.
@@ -0,0 +1 @@ | |||
a~this() No newline at end of file |
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.
Let's add a failing test with a reserved word like yield
, to ensure it's not later changed to an incorrect impl. Instead of expected.json add an options.json with a "throws" key (check other files for examples )
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.
Done.
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.
Awesome!
Resolve issues with using
this
as the object of a tilde call:The above will now transform correctly to: