Giter Club home page Giter Club logo

Comments (2)

tvcutsem avatar tvcutsem commented on May 9, 2024

Thanks for reporting. I know what causes the error, but am not yet sure how to fix it. I will send e-mail to es-discuss to discuss the best fix to the problem.

In a nutshell, what happens is the following:

fp.prototype = {} // this triggers the proxy's "set" trap
// since the "set" trap is not defined, the proxy defaults to calling:
Reflect.set(f, 'prototype', {}, fp) // note: the proxy fp itself is being passed as the "receiver" argument to Reflect.set

Inside Reflect.set, a test is made to check whether f === fp.
If this test is true, Reflect.set tries to update the existing 'prototype' property to the "receiver"
If this test is false, Reflect.set tries to add a new data property to the "receiver"

Since f === fp will fail, Reflect.set tries to add the data property {value: {}, enumerable:true, writable: true, configurable:true } to fp. The proxy in turn forwards this operation and tries to add the property to f, which fails because f already defines a property with the same name which is non-configurable, and one cannot change a non-configurable property into a configurable property.

There are a couple of fixes:

  1. let the default "set" trap forward the operation as
    Reflect.set(f, 'prototype', {}, f) rather than Reflect.set(f, 'prototype', {}, fp)

  2. change the f === fp test in Reflect.set to take proxies into account explicitly, and change it to:
    (f === fp || fp is a proxy for f)

from harmony-reflect.

tvcutsem avatar tvcutsem commented on May 9, 2024

The issue has been fixed. See commit notes referenced above.

from harmony-reflect.

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.