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

compiler: Add todo for getter/setter syntax #29592

Merged
merged 1 commit into from
May 29, 2024
Merged
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 @@ -1520,6 +1520,15 @@ function lowerExpression(
place,
});
} else if (propertyPath.isObjectMethod()) {
if (propertyPath.node.kind !== "method") {
builder.errors.push({
reason: `(BuildHIR::lowerExpression) Handle ${propertyPath.node.kind} functions in ObjectExpression`,
severity: ErrorSeverity.Todo,
loc: propertyPath.node.loc ?? null,
suggestions: null,
});
continue;
}
const method = lowerObjectMethod(builder, propertyPath);
const place = lowerValueToTemporary(builder, method);
const loweredKey = lowerObjectPropertyKey(builder, propertyPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

## Input

```javascript
function Component({ value }) {
const object = {
get value() {
return value;
},
};
return <div>{object.value}</div>;
}

export const FIXTURE_ENTRYPOINT = {
fn: foo,
params: [{ value: 0 }],
sequentialRenders: [{ value: 1 }, { value: 2 }],
};

```


## Error

```
1 | function Component({ value }) {
2 | const object = {
> 3 | get value() {
| ^^^^^^^^^^^^^
> 4 | return value;
| ^^^^^^^^^^^^^^^^^^^
> 5 | },
| ^^^^^^ Todo: (BuildHIR::lowerExpression) Handle get functions in ObjectExpression (3:5)
6 | };
7 | return <div>{object.value}</div>;
8 | }
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function Component({ value }) {
const object = {
get value() {
return value;
},
};
return <div>{object.value}</div>;
}

export const FIXTURE_ENTRYPOINT = {
fn: foo,
params: [{ value: 0 }],
sequentialRenders: [{ value: 1 }, { value: 2 }],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

## Input

```javascript
function Component(props) {
let value;
const object = {
set value(v) {
value = v;
},
};
object.value = props.value;
return <div>{value}</div>;
}

export const FIXTURE_ENTRYPOINT = {
fn: foo,
params: [{ value: 0 }],
sequentialRenders: [{ value: 1 }, { value: 2 }],
};

```


## Error

```
2 | let value;
3 | const object = {
> 4 | set value(v) {
| ^^^^^^^^^^^^^^
> 5 | value = v;
| ^^^^^^^^^^^^^^^^
> 6 | },
| ^^^^^^ Todo: (BuildHIR::lowerExpression) Handle set functions in ObjectExpression (4:6)
7 | };
8 | object.value = props.value;
9 | return <div>{value}</div>;
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function Component(props) {
let value;
const object = {
set value(v) {
value = v;
},
};
object.value = props.value;
return <div>{value}</div>;
}

export const FIXTURE_ENTRYPOINT = {
fn: foo,
params: [{ value: 0 }],
sequentialRenders: [{ value: 1 }, { value: 2 }],
};