Skip to content
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

Delete applied to private name via optional chain #2665

Open
mgaudet opened this issue Jun 17, 2020 · 7 comments
Open

Delete applied to private name via optional chain #2665

mgaudet opened this issue Jun 17, 2020 · 7 comments
Labels

Comments

@mgaudet
Copy link

mgaudet commented Jun 17, 2020

I think a test case for SyntaxError on delete o?.#x needs to be added.

@rwaldron
Copy link
Contributor

@leobalter does this fall in scope for the refactoring you wanted to do?

@leobalter
Copy link
Member

leobalter commented Jul 15, 2020

This is not covered.

I did some work on optional chaining but missed covering optional chain as UnaryExpressions.

Funny enough, delete {}?.x is valid.

The version with private fields is a SyntaxError regardless of the delete.

// valid
class C {
  #x = 42;
  m() {
    var o = this;
    return o.#x;
  }
}

// SyntaxError
class C {
  #x = 42;
  m() {
    var o = this;
    return o?.#x;
  }
}

We might coverage for private fields + optional chain, but needs verification.

@mgaudet
Copy link
Author

mgaudet commented Jul 15, 2020

I don't think that second example is a syntax error since tc39/proposal-class-fields#301

@leobalter
Copy link
Member

Thanks! I was not up to date with the private fields proposal and then we just need to verify coverage.

@mgaudet can you help me pointing to the part where delete o?.x would be forbidden?

@leobalter
Copy link
Member

I found it: https://tc39.es/proposal-class-fields/#sec-static-semantics-early-errors

@caiolima
Copy link
Contributor

IIRC, we had tests to cover that o?.#x was a SyntaxError and this got reverted into #2566. I don't remember seeing or adding any test that covers delete o?.#x though.

@rwaldron
Copy link
Contributor

Is there any further action to take in Test262?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants