Skip to content

[CS2]: Fix #4591: multiple accesses after super #4592

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

Merged
merged 4 commits into from
Jul 13, 2017

Conversation

helixbass
Copy link
Collaborator

Surprisingly, just wrapping a new Value() around the Super in the grammar didn't seem to break anything and made super.x.y and super['x'].y work

Just looking through references to Super in nodes.coffee, I didn't see anything that looked like it would need updating, but there could be gotchas I'm not aware of

@@ -1808,3 +1808,19 @@ test 'Bound method of immediately instantiated class with expression base class

{derivedBound} = a
eq derivedBound(), 3

test "#4591: super.x.y, super['x'].y", ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usually super.foo refers to a method named foo, as in super.foo(). We should add another test that tests super.x.y() and super['x'].y()

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also super.x['y'] and super.x['y']().

Copy link
Collaborator

@vendethiel vendethiel Jun 27, 2017

Choose a reason for hiding this comment

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

well, super.foo still has the implicit call there – it means super(arguments...).foo, so why'd that case be special?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vendethiel that changed in 2 to support ES-style super invocations. Compare bare super, super with parens, super with access, and super with both.

Deeper accesses against a super field could be useful if you're trying to bind/call/apply it, I guess.

class A
  f: -> super.f.apply(this, arguments)

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, I didn't follow that. That's good to know

Copy link
Collaborator

Choose a reason for hiding this comment

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

@helixbass do you mind adding these additional tests, unless there’s some reason they don’t make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@GeoffreyBooth added tests for the cases you outlined

@connec that's a more realistic use case than anything I thought of, I just noticed the hole in the grammar

@GeoffreyBooth
Copy link
Collaborator

@helixbass if you don’t mind merging and resolving conflicts, I think this is ready. @lydell, @vendethiel or @connec, any notes?

@vendethiel
Copy link
Collaborator

super:: is not allowed – is that useful, and do we want to allow it?

@vendethiel
Copy link
Collaborator

vendethiel commented Jul 6, 2017

Also, that error is pretty surprising (it's not from this PR, this happens as well on 2):
Even if that wants to be disallowed, I think the error should point to super.

$ ./bin/coffee -bce "class then a: -> super"  
[stdin]:1:15: error: unexpected ->
class then a: -> super

@vendethiel
Copy link
Collaborator

WRT #4601:
On 2 right now:

$ ./bin/coffee -bce 'super"b"'
[stdin]:1:6: error: unexpected string
super"b"

This PR hasn't been rebased yet, so the same error happens. Once rebased I think it should work, but we might want to add a test.

@helixbass
Copy link
Collaborator Author

@GeoffreyBooth merged 2 and resolved conflicts

@vendethiel none of those seem directly relevant to this PR (or #4601). I don't know if super"b" (ie super as the "function" of a tagged template literal) actually makes sense or not but it wouldn't start working b/c of this PR or #4601, in 2 super (the token) is only currently allowed in the grammar as part of a Super (ie super with access/index) or an Invocation (ie super(...)) so you'd need an additional rule to allow it with a tagged template literal

@GeoffreyBooth
Copy link
Collaborator

@connec or @vendethiel or @lydell, any other notes?

@vendethiel
Copy link
Collaborator

Nope. If needed we can revisit the rest later.

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.

4 participants