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

fix(react-compiler): implement NumericLiteral as ObjectPropertyKey #31791

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,11 @@ function lowerObjectPropertyKey(
kind: 'identifier',
name: key.node.name,
};
} else if (key.isNumericLiteral()) {
return {
kind: 'identifier',
name: String(key.node.value),
}
}

builder.errors.push({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

## Input

```javascript
function Test() {
const obj = {
21: 'dimaMachina'
}
return <div>{obj[21]}</div>
}

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
function Test() {
const $ = _c(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const obj = { 21: "dimaMachina" };

t0 = <div>{obj[21]}</div>;
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
}

```

### Eval output
(kind: exception) Fixture not implemented
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function Test() {
const obj = {
21: 'dimaMachina'
}
return <div>{obj[21]}</div>
}