react icon indicating copy to clipboard operation
react copied to clipboard

compiler: add built-in Object.prototype methods to ShapeRegistry

Open saul-atomrigs opened this issue 1 year ago • 4 comments

This PR enhances the ShapeRegistry by incorporating additional Object.prototype methods from the TODO. In this implementation:

  • toLocaleString is similar to the existing toString method: it takes no arguments and returns a primitive value (string).
  • hasOwnProperty, isPrototypeOf, and propertyIsEnumerable all take one argument and return a primitive (boolean).
  • valueOf takes no arguments and returns a poly type(the this value, converted to an object.).

References:

  • toLocaleString: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString
  • hasOwnProperty: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
  • isPrototypeOf: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf
  • propertyIsEnumerable: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable
  • valueOf: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf

saul-atomrigs avatar Jun 26 '24 17:06 saul-atomrigs

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 6:56am

vercel[bot] avatar Jun 26 '24 17:06 vercel[bot]

Comparing: 7baae65e767726e44a23c13203c05ae0d540e26f...20740de620736abd7dbf8c348019a8d451376221

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.93 kB 497.93 kB = 89.26 kB 89.26 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.75 kB 502.75 kB = 89.96 kB 89.96 kB
facebook-www/ReactDOM-prod.classic.js = 597.10 kB 597.10 kB = 105.31 kB 105.31 kB
facebook-www/ReactDOM-prod.modern.js = 571.44 kB 571.44 kB = 101.24 kB 101.24 kB
test_utils/ReactAllWarnings.js Deleted 62.88 kB 0.00 kB Deleted 15.69 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 62.88 kB 0.00 kB Deleted 15.69 kB 0.00 kB

Generated by :no_entry_sign: dangerJS against 20740de620736abd7dbf8c348019a8d451376221

react-sizebot avatar Jun 26 '24 17:06 react-sizebot

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

github-actions[bot] avatar Oct 09 '24 01:10 github-actions[bot]

Oops, we missed this. I’ll review properly tomorrow

josephsavona avatar Oct 09 '24 02:10 josephsavona

Hello @josephsavona, I was wondering if you had a chance to have a look at this PR 👀..

saul-atomrigs avatar Oct 24 '24 09:10 saul-atomrigs

@josephsavona I'm getting this:

  4 |   const x = {
  5 |     valueOf() {
> 6 |       return this;
    |              ^^^^ Todo: (BuildHIR::lowerExpression) Handle ThisExpression expressions (6:6)
  7 |     }
  8 |   };
  9 |   x.valueOf().y = true;

Is this error expected?

If so, may I just document it like here?: https://github.com/facebook/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/tests/fixtures/compiler/error.todo-object-expression-set-syntax.expect.md#error

saul-atomrigs avatar Oct 25 '24 04:10 saul-atomrigs

Hello @josephsavona , I added the fixture as stated above and would appreciate your review! Thanks!

saul-atomrigs avatar Oct 30 '24 04:10 saul-atomrigs

@josephsavona This PR is ready for review! Thanks for your time 🙂

saul-atomrigs avatar Nov 01 '24 01:11 saul-atomrigs

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

github-actions[bot] avatar Jan 30 '25 01:01 github-actions[bot]

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

github-actions[bot] avatar Feb 06 '25 01:02 github-actions[bot]