Skip to content

Conversation

haltcase
Copy link

Q A
Bug fix? yes
Breaking change? no
New feature? no
Deprecations? no
Spec compliancy? no
Tests added/pass? yes
Fixed tickets #29
License MIT

Resolve issues with using this as the object of a tilde call:

a~this()

The above will now transform correctly to:

this(a)

// 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') {
Copy link

@wcjohnson wcjohnson Apr 27, 2017

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

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();
} ...

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

Copy link
Author

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.

Copy link

@rattrayalex rattrayalex left a 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

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)

Copy link
Author

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

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

Copy link
Author

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

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 )

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Copy link

@rattrayalex rattrayalex left a comment

Choose a reason for hiding this comment

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

Awesome!

@rattrayalex rattrayalex merged commit ead0fc1 into lightscript:lightscript Apr 27, 2017
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