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

Normative: add #x in obj syntax #2290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

@ljharb
Copy link
Member

@ljharb ljharb commented Jan 27, 2021

This PR is based on top of #1668. Please review by commit. As #1668 is updated and/or merged, I'll rebase this one.

@ljharb ljharb requested review from syg, michaelficarra, bakkot and tc39/ecma262-editors Jan 27, 2021
@ljharb ljharb mentioned this pull request Jan 27, 2021
24 of 25 tasks
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from 37b4f60 to 17d9044 Jan 27, 2021
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from 17d9044 to b95c824 Jan 28, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Jan 28, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from b95c824 to 3ad18be Jan 28, 2021
@ljharb
Copy link
Member Author

@ljharb ljharb commented Jan 28, 2021

I've split out all the fixes you requested that aren't part of this PR, but are instead part of #1668, into a separate commit. Please only review the last commit here :-)

@ljharb ljharb requested a review from jmdyck Jan 28, 2021
@jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented Jan 28, 2021

Sorry, I wasn't paying enough attention (re #1668).

ljharb added a commit to ljharb/ecma262 that referenced this pull request Feb 5, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from 3ad18be to 5349602 Feb 5, 2021
spec.html Outdated Show resolved Hide resolved
ljharb added a commit to ljharb/ecma262 that referenced this pull request Feb 5, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from 5349602 to e3c5cd5 Feb 5, 2021
@ljharb ljharb requested a review from jridgewell Feb 5, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Feb 8, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from e3c5cd5 to d113e4f Feb 8, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Mar 31, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from d113e4f to d7c3c84 Mar 31, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Apr 27, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from d7c3c84 to da72c39 Apr 27, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request May 7, 2021
@WebReflection
Copy link

@WebReflection WebReflection commented Jun 28, 2021

as #x has to be declared at the class level, hence always known, in which circumstance #x in this would fail, if I might ask?

@bakkot
Copy link
Contributor

@bakkot bakkot commented Jun 28, 2021

#x in this will never throw, but it can return false if you do something like

class A {
  #x = 0;
  hasX() {
    return #x in this;
  }
}
A.prototype.hasX.call({}); // false
@WebReflection
Copy link

@WebReflection WebReflection commented Jun 28, 2021

@bakkot thanks, but isn't that a violation of the meaning of "private"?

@bakkot
Copy link
Contributor

@bakkot bakkot commented Jun 28, 2021

No? It's only the class which is able to do this check; you can't write #x in this outside of A.

@ljharb
Copy link
Member Author

@ljharb ljharb commented Jun 28, 2021

@WebReflection this isn't the only object that can hold a private field; imagine static compare(a, b) { return #x in a && #x in b && a.#x === b.#x; }

@WebReflection
Copy link

@WebReflection WebReflection commented Jun 28, 2021

OK, the class “owns” the private field access, but I wonder what a Proxy trap would do there, and if this check could lead to “leaking” exploits. If Proxy can’t intercept these check then fine, but I didn’t read anything about proxies in the text. If I missed that, no issue, if I didn’t, are private fields leaking via Proxy traps?

@ljharb
Copy link
Member Author

@ljharb ljharb commented Jun 28, 2021

@WebReflection Proxy has no ability to detect or intercept private fields, or internal slots.

If there's further discussion to be had, can we have it in the discourse or on the proposal repo, instead of here on the spec PR?

@WebReflection
Copy link

@WebReflection WebReflection commented Jun 28, 2021

Thanks! Please ignore my comments then, I had a mix of a-aha and “the heck?” moment there. All good 👍

@syg
syg approved these changes Jun 28, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Jun 29, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from 791f910 to c274ab1 Jun 29, 2021
@ljharb ljharb force-pushed the tc39:master branch from 93e58e8 to 3d4ae86 Jun 29, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Jun 29, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from c274ab1 to b1911ec Jun 29, 2021
@ljharb ljharb force-pushed the tc39:master branch from 3d4ae86 to 1320e04 Jun 29, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Jun 29, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from b1911ec to de8ba37 Jun 29, 2021
@ljharb ljharb force-pushed the tc39:master branch from 1320e04 to 3d0c24c Jun 29, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Jun 29, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from de8ba37 to 66a3f9e Jun 29, 2021
@ljharb ljharb force-pushed the tc39:master branch from 3d0c24c to 7a79833 Jun 29, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Jun 29, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from 66a3f9e to f9f006c Jun 29, 2021
ljharb added a commit to ljharb/ecma262 that referenced this pull request Jun 29, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from f9f006c to a060ea8 Jun 29, 2021
@ljharb ljharb force-pushed the ljharb:private-fields-in-in branch from a060ea8 to e172a6e Jul 14, 2021
@ljharb ljharb requested a review from tc39/ecma262-editors Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants