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] Repro: updates to globals should be retained #30470

Merged
merged 3 commits into from
Jul 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
@@ -0,0 +1,32 @@

## Input

```javascript
let renderCount = 0;
function useFoo() {
renderCount += 1;
return renderCount;
}

export const FIXTURE_ENTRYPOINT = {
fn: useFoo,
params: [],
};

```

## Code

```javascript
let renderCount = 0;
function useFoo() {
return renderCount;
}

export const FIXTURE_ENTRYPOINT = {
fn: useFoo,
params: [],
};

```

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let renderCount = 0;
function useFoo() {
renderCount += 1;
return renderCount;
}

export const FIXTURE_ENTRYPOINT = {
fn: useFoo,
params: [],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

## Input

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

let renderCount = 0;
function Foo() {
const cb = () => {
renderCount += 1;
return renderCount;
};
return <Stringify cb={cb} shouldInvokeFns={true} />;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [{}],
};

```

## Code

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

let renderCount = 0;
function Foo() {
const $ = _c(1);
const cb = _temp;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <Stringify cb={cb} shouldInvokeFns={true} />;
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
}
function _temp() {
return renderCount;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [{}],
};

```

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Stringify} from 'shared-runtime';

let renderCount = 0;
function Foo() {
const cb = () => {
renderCount += 1;
return renderCount;
};
return <Stringify cb={cb} shouldInvokeFns={true} />;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [{}],
};
2 changes: 2 additions & 0 deletions compiler/packages/snap/src/SproutTodoFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ const skipFilter = new Set([
'rules-of-hooks/rules-of-hooks-69521d94fa03',

// bugs
'bug-invalid-update-global-should-bailout',
'bug-update-global-in-callback',
'bug-invalid-hoisting-functionexpr',
'original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block',
'original-reactive-scopes-fork/bug-hoisted-declaration-with-scope',
Expand Down