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] Fix broken tests #31078

Merged
merged 4 commits into from
Sep 26, 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 @@ -19,15 +19,17 @@ function Component() {
);
}

function cx(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
const cx = {
foo(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
}
}
}
return classes.join(' ');
}
return classes.join(' ');
},
};

function useTheme() {
return {
Expand Down Expand Up @@ -71,15 +73,17 @@ function Component() {
return t1;
}

function cx(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
const cx = {
foo(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
}
}
}
return classes.join(" ");
}
return classes.join(" ");
},
};

function useTheme() {
return {
Expand All @@ -97,4 +101,4 @@ export const FIXTURE_ENTRYPOINT = {
```

### Eval output
(kind: exception) cx.foo is not a function
(kind: ok) <div class="styles/light styles/dark"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ function Component() {
);
}

function cx(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
const cx = {
foo(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
}
}
}
return classes.join(' ');
}
return classes.join(' ');
},
};

function useTheme() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
```javascript
import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* There are three values with their own scopes in this fixture.
* - arr, whose mutable range extends to the `mutate(...)` call
Expand Down Expand Up @@ -45,6 +47,8 @@ export const FIXTURE_ENTRYPOINT = {
import { c as _c } from "react/compiler-runtime";
import { CONST_TRUE, identity, shallowCopy } from "shared-runtime";

function mutate(_) {}

/**
* There are three values with their own scopes in this fixture.
* - arr, whose mutable range extends to the `mutate(...)` call
Expand Down Expand Up @@ -91,4 +95,4 @@ export const FIXTURE_ENTRYPOINT = {
```

### Eval output
(kind: exception) mutate is not defined
(kind: ok)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* There are three values with their own scopes in this fixture.
* - arr, whose mutable range extends to the `mutate(...)` call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import {useCallback} from 'react';
import {identity, useIdentity} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
Expand Down Expand Up @@ -33,6 +35,8 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe
import { useCallback } from "react";
import { identity, useIdentity } from "shared-runtime";

function mutate(_) {}

/**
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
Expand Down Expand Up @@ -62,4 +66,4 @@ export const FIXTURE_ENTRYPOINT = {
```

### Eval output
(kind: exception) mutate is not defined
(kind: ok) "[[ function params=0 ]]"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import {useCallback} from 'react';
import {identity, useIdentity} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
```javascript
import {identity, makeObject_Primitives} from 'shared-runtime';

function useHook() {}

function useTest({cond}) {
const val = makeObject_Primitives();

Expand Down Expand Up @@ -31,6 +33,8 @@ export const FIXTURE_ENTRYPOINT = {
import { c as _c } from "react/compiler-runtime";
import { identity, makeObject_Primitives } from "shared-runtime";

function useHook() {}

function useTest(t0) {
const $ = _c(3);
const { cond } = t0;
Expand Down Expand Up @@ -64,4 +68,4 @@ export const FIXTURE_ENTRYPOINT = {
```

### Eval output
(kind: exception) useHook is not defined
(kind: ok) {"a":0,"b":"value1","c":true}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {identity, makeObject_Primitives} from 'shared-runtime';

function useHook() {}

function useTest({cond}) {
const val = makeObject_Primitives();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Input

```javascript
import {makeObject_Primitives} from 'shared-runtime';
import {makeObject_Primitives, Stringify} from 'shared-runtime';

function Component(props) {
let useFeature = makeObject_Primitives();
Expand Down Expand Up @@ -32,7 +32,7 @@ export const FIXTURE_ENTRYPOINT = {

```javascript
import { c as _c } from "react/compiler-runtime";
import { makeObject_Primitives } from "shared-runtime";
import { makeObject_Primitives, Stringify } from "shared-runtime";

function Component(props) {
const $ = _c(2);
Expand Down Expand Up @@ -75,4 +75,4 @@ export const FIXTURE_ENTRYPOINT = {
```

### Eval output
(kind: exception) Stringify is not defined
(kind: ok) <div>{"val":{"a":0,"b":"value1","c":true},"children":[2,"[[ cyclic ref *1 ]]",null]}</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeObject_Primitives} from 'shared-runtime';
import {makeObject_Primitives, Stringify} from 'shared-runtime';

function Component(props) {
let useFeature = makeObject_Primitives();
Expand Down