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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/classes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1808,3 +1808,28 @@ 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

class A
x:
y: 1
z: -> 2

class B extends A
constructor: ->
super()

@w = super.x.y
@v = super['x'].y
@u = super.x['y']
@t = super.x.z()
@s = super['x'].z()
@r = super.x['z']()

b = new B
eq 1, b.w
eq 1, b.v
eq 1, b.u
eq 2, b.t
eq 2, b.s
eq 2, b.r