Giter Site home page Giter Site logo

Comments (9)

littledan avatar littledan commented on July 30, 2024

I don't see why a field named constructor (whether it's static or instance) would need any special treatment. We talked about special treatment for fields named __proto__ in the past, but really, there's no particular interaction in either case. If there's a public instance field named constructor, then a constructor property is simply added to the instance with [[DefineOwnProperty]] at the appropriate time in the [[Construct]] sequence. You can still get at the "real" constructor through instance.__proto__.constructor. Do you think we should ban this, though, to avoid confusion?

There's definitely a bug about PropName being misapplied, which I see in one place: when prohibiting static fields named prototype. I'll fix that up; thanks for the catch.

from proposal-class-fields.

littledan avatar littledan commented on July 30, 2024

What do you think of this fix?

from proposal-class-fields.

waldemarhorwat avatar waldemarhorwat commented on July 30, 2024

It's not fixed. The PropName call and disallowance of "constructor" I was referring to are coming from NonConstructorMethodDefinitions, which is called by ClassDefinitionEvaluation.

from proposal-class-fields.

rwaldron avatar rwaldron commented on July 30, 2024

from proposal-class-fields.

waldemarhorwat avatar waldemarhorwat commented on July 30, 2024

Huh?

https://tc39.github.io/proposal-class-fields/#runtime-semantics-class-definition-evaluation
calls NonConstructorMethodDefinitions, which calls PropName on something on which it's not defined. And it will silently drop any fields named constructor.

from proposal-class-fields.

rwaldron avatar rwaldron commented on July 30, 2024

I was providing links to the sections you mentioned in your comment, for others that might read this thread.

from proposal-class-fields.

littledan avatar littledan commented on July 30, 2024

@waldemarhorwat Thanks, I wasn't thinking about that path (but I believe the other one was a bug as well); will fix.

from proposal-class-fields.

waldemarhorwat avatar waldemarhorwat commented on July 30, 2024

NonConstructorElementDefinitions currently starts with:
If ClassElement is any of ClassElement:; , FieldDefinition:; or , return a new empty List.
I don't know what that is referring to; that doesn't parse and there are no such grammar productions.

from proposal-class-fields.

littledan avatar littledan commented on July 30, 2024

@waldemarhorwat Thanks for pointing this out; I should've checked the generated output more closely (the colon doesn't appear in the source but was inserted by grammardown). Uploading a fix in a minute.

from proposal-class-fields.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.