From de89ed32a2b649ad542a4f3387312aa3c171d3a7 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Tue, 18 Apr 2023 11:12:27 -0700 Subject: [PATCH] Use implicit return (undefined) Making ReturnTerminal.value non-nullable broke our optimization to elide final value-less return statements. We now check if a return value is explicitly `undefined` and elide the value in this case, which then also propagates to allow removing the final `return` statement of a function if the value is missing. --- .../ReactiveScopes/CodegenReactiveFunction.ts | 4 +++ ...g.computed-call-evaluation-order.expect.md | 1 - ...g.property-call-evaluation-order.expect.md | 1 - .../fixtures/compiler/alias-while.expect.md | 4 +-- .../fixtures/compiler/call.expect.md | 4 +-- .../compiler/conditional-on-mutable.expect.md | 8 ++---- .../fixtures/compiler/constructor.expect.md | 4 +-- .../fixtures/compiler/early-return.expect.md | 4 +-- .../fixtures/compiler/for-return.expect.md | 3 +-- .../compiler/frozen-after-alias.expect.md | 8 ++---- .../fixtures/compiler/hook-call.expect.md | 8 ++---- .../compiler/hooks-freeze-arguments.expect.md | 8 ++---- ...reeze-possibly-mutable-arguments.expect.md | 8 ++---- .../compiler/independent-across-if.expect.md | 16 +++--------- .../fixtures/compiler/independent.expect.md | 12 +++------ .../interdependent-across-if.expect.md | 12 +++------ .../compiler/interdependent.expect.md | 12 +++------ .../fixtures/compiler/issue852.expect.md | 1 - .../compiler/mutable-lifetime-loops.expect.md | 9 ++----- .../mutable-lifetime-with-aliasing.expect.md | 5 +--- .../compiler/mutable-liverange-loop.expect.md | 9 ++----- ...bject-computed-access-assignment.expect.md | 1 - .../compiler/object-properties.expect.md | 1 - ...g-scopes-interleaved-by-terminal.expect.md | 1 - .../overlapping-scopes-interleaved.expect.md | 1 - .../overlapping-scopes-shadowed.expect.md | 1 - .../overlapping-scopes-while.expect.md | 1 - .../compiler/return-undefined.expect.md | 25 +++++++++++++++++++ .../fixtures/compiler/return-undefined.js | 6 +++++ .../compiler/reverse-postorder.expect.md | 1 - .../compiler/sequence-expression.expect.md | 4 +-- .../fixtures/compiler/simple-alias.expect.md | 4 +-- .../compiler/ssa-call-jsx-2.expect.md | 4 +-- .../fixtures/compiler/ssa-call-jsx.expect.md | 4 +-- .../ssa-complex-multiple-if.expect.md | 4 +-- .../compiler/ssa-complex-single-if.expect.md | 4 +-- .../fixtures/compiler/ssa-if-else.expect.md | 4 +-- .../compiler/ssa-nested-partial-phi.expect.md | 1 - .../compiler/ssa-newexpression.expect.md | 4 +-- .../fixtures/compiler/ssa-shadowing.expect.md | 5 +--- .../compiler/ssa-sibling-phis.expect.md | 4 +-- .../compiler/ssa-simple-phi.expect.md | 4 +-- .../fixtures/compiler/ssa-simple.expect.md | 4 +-- .../fixtures/compiler/ssa-single-if.expect.md | 4 +-- .../fixtures/compiler/ssa-switch.expect.md | 1 - .../switch-with-fallthrough.expect.md | 1 - .../transitive-alias-fields.expect.md | 1 - .../type-args-test-binary-operator.expect.md | 1 - .../compiler/type-binary-operator.expect.md | 1 - .../compiler/useMemo-return-empty.expect.md | 1 - .../while-conditional-continue.expect.md | 1 - 51 files changed, 82 insertions(+), 158 deletions(-) create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/return-undefined.expect.md create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/return-undefined.js diff --git a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts index 73fa1b4201..cf93ec0045 100644 --- a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -388,6 +388,10 @@ function codegenTerminal( } case "return": { const value = codegenPlace(cx, terminal.value); + if (value.type === "Identifier" && value.name === "undefined") { + // Use implicit undefined + return t.returnStatement(); + } return t.returnStatement(value); } case "switch": { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md index c3f6d691c9..c76469d485 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md @@ -26,7 +26,6 @@ function Component() { import * as React from "react"; // Should print A, B, arg, original function changeF(o) { o.f = () => console.log("new"); - return undefined; } function Component() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md index d19fc984d0..ad665dabf4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md @@ -26,7 +26,6 @@ import * as React from "react"; // Should print A, arg, original function changeF(o) { o.f = () => console.log("new"); - return undefined; } function Component() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md index 46066bf54d..ef30f567ae 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md @@ -50,9 +50,7 @@ function foo(cond) { return a; } -function mutate(x, y) { - return undefined; -} +function mutate(x, y) {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md index 6753b86351..e71e9f6248 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md @@ -19,9 +19,7 @@ function Component(props) { ```javascript import * as React from "react"; -function foo() { - return undefined; -} +function foo() {} function Component(props) { const $ = React.unstable_useMemoCache(3); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md index bb048d86bf..36fca5fc35 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md @@ -105,12 +105,8 @@ function ComponentB(props) { return t0; } -function Foo() { - return undefined; -} -function mayMutate() { - return undefined; -} +function Foo() {} +function mayMutate() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md index b4d74e5871..5d086b85d7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md @@ -19,9 +19,7 @@ function Component(props) { ```javascript import * as React from "react"; -function Foo() { - return undefined; -} +function Foo() {} function Component(props) { const $ = React.unstable_useMemoCache(3); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/early-return.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/early-return.expect.md index 1de1b17505..fbe27fb900 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/early-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/early-return.expect.md @@ -18,9 +18,9 @@ function MyApp(props) { ```javascript function MyApp(props) { if (props.cond) { - return undefined; + return; } else { - return undefined; + return; } } diff --git a/compiler/forget/src/__tests__/fixtures/compiler/for-return.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/for-return.expect.md index 669a3d2042..5670e40374 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/for-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/for-return.expect.md @@ -15,9 +15,8 @@ function Component(props) { ```javascript function Component(props) { for (const i = 0; 0 < props.count; ) { - return undefined; + return; } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md index cc6845fcec..b0d1155d7b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md @@ -35,12 +35,8 @@ function Component() { return b; } -function useFreeze() { - return undefined; -} -function foo(x) { - return undefined; -} +function useFreeze() {} +function foo(x) {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md index 2e3be7662e..96a01b7347 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md @@ -23,12 +23,8 @@ function Component(props) { ```javascript import * as React from "react"; -function useFreeze() { - return undefined; -} -function foo() { - return undefined; -} +function useFreeze() {} +function foo() {} function Component(props) { const $ = React.unstable_useMemoCache(3); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md index 885950e679..742c756353 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md @@ -35,12 +35,8 @@ function Component() { return a; } -function useFreeze(x) { - return undefined; -} -function call(x) { - return undefined; -} +function useFreeze(x) {} +function call(x) {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md index e884906781..46758fa2f2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md @@ -50,12 +50,8 @@ function Component(props) { return a; } -function useFreeze(x) { - return undefined; -} -function call(x) { - return undefined; -} +function useFreeze(x) {} +function call(x) {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md index 119c630446..bf33e6b5bf 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md @@ -37,18 +37,10 @@ function Component(props) { ```javascript import * as React from "react"; -function compute() { - return undefined; -} -function mutate() { - return undefined; -} -function foo() { - return undefined; -} -function Foo() { - return undefined; -} +function compute() {} +function mutate() {} +function foo() {} +function Foo() {} /** * Should produce 3 scopes: diff --git a/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md index c2d3c3375c..1d6b4fe15d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md @@ -74,15 +74,9 @@ function Component(props) { return t2; } -function compute() { - return undefined; -} -function foo() { - return undefined; -} -function Foo() { - return undefined; -} +function compute() {} +function foo() {} +function Foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md index d6eb9dea52..eb58aca30f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md @@ -31,15 +31,9 @@ function Component(props) { ```javascript import * as React from "react"; -function compute() { - return undefined; -} -function foo() { - return undefined; -} -function Foo() { - return undefined; -} +function compute() {} +function foo() {} +function Foo() {} /** * Should produce 1 scope: diff --git a/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md index 3c49a5d13a..f909625a97 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md @@ -69,15 +69,9 @@ function Component(props) { return t0; } -function compute() { - return undefined; -} -function foo() { - return undefined; -} -function Foo() { - return undefined; -} +function compute() {} +function foo() {} +function Foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/issue852.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/issue852.expect.md index a42641612a..585f8761c4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/issue852.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/issue852.expect.md @@ -17,7 +17,6 @@ function Component(c) { function Component(c) { const x = { c }; mutate(x); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-loops.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-loops.expect.md index bc7f2ac4fd..53759f7a3d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-loops.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-loops.expect.md @@ -42,12 +42,8 @@ function Component(props) { ## Code ```javascript -function mutate(x, y) { - return undefined; -} -function cond(x) { - return undefined; -} +function mutate(x, y) {} +function cond(x) {} function Component(props) { let a = {}; @@ -75,7 +71,6 @@ function Component(props) { } mutate(d, null); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-with-aliasing.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-with-aliasing.expect.md index b061189d05..e8c6859c0b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-with-aliasing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/mutable-lifetime-with-aliasing.expect.md @@ -38,9 +38,7 @@ function Component(props) { ## Code ```javascript -function mutate(x, y) { - return undefined; -} +function mutate(x, y) {} function Component(props) { const a = {}; @@ -63,7 +61,6 @@ function Component(props) { } mutate(x, null); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/mutable-liverange-loop.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/mutable-liverange-loop.expect.md index f45e178230..62501bfb6f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/mutable-liverange-loop.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/mutable-liverange-loop.expect.md @@ -37,12 +37,8 @@ function Component(props) { ## Code ```javascript -function mutate() { - return undefined; -} -function cond() { - return undefined; -} +function mutate() {} +function cond() {} function Component(props) { const a = {}; @@ -65,7 +61,6 @@ function Component(props) { } mutate(d, null); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/object-computed-access-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/object-computed-access-assignment.expect.md index 647fa04919..43de30d2a9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/object-computed-access-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/object-computed-access-assignment.expect.md @@ -15,7 +15,6 @@ function foo(a, b, c) { function foo(a, b, c) { a[b] = c[b]; a[3] = c[b * 4]; - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/object-properties.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/object-properties.expect.md index 6d36212265..6dd40f5555 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/object-properties.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/object-properties.expect.md @@ -19,7 +19,6 @@ function foo(a, b, c) { const y = b.c.d; y.z = c.d.e; foo(a.b.c); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved-by-terminal.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved-by-terminal.expect.md index d63885a360..ee03be5071 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved-by-terminal.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved-by-terminal.expect.md @@ -26,7 +26,6 @@ function foo(a, b, c) { y.push(a); x.push(b); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved.expect.md index 35942cbe22..dd0dc7aa43 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-interleaved.expect.md @@ -19,7 +19,6 @@ function foo(a, b) { const y = []; x.push(a); y.push(b); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowed.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowed.expect.md index c6302d49e3..55e86925bf 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowed.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowed.expect.md @@ -19,7 +19,6 @@ function foo(a, b) { const y = []; y.push(b); x.push(a); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-while.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-while.expect.md index 64e66ee2da..2f7144a106 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-while.expect.md @@ -23,7 +23,6 @@ function foo(a, b, c) { y.push(b); x.push(a); } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/return-undefined.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/return-undefined.expect.md new file mode 100644 index 0000000000..87b31f99ff --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/return-undefined.expect.md @@ -0,0 +1,25 @@ + +## Input + +```javascript +function Component(props) { + if (props.cond) { + return undefined; + } + return props.value; +} + +``` + +## Code + +```javascript +function Component(props) { + if (props.cond) { + return; + } + return props.value; +} + +``` + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/return-undefined.js b/compiler/forget/src/__tests__/fixtures/compiler/return-undefined.js new file mode 100644 index 0000000000..892e84a49d --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/return-undefined.js @@ -0,0 +1,6 @@ +function Component(props) { + if (props.cond) { + return undefined; + } + return props.value; +} diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reverse-postorder.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reverse-postorder.expect.md index ebbff2f3b8..2530479763 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reverse-postorder.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reverse-postorder.expect.md @@ -54,7 +54,6 @@ function Component(props) { } else { } } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md index c06c5b7e94..b13e55e420 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md @@ -42,9 +42,7 @@ function sequence(props) { return x; } -function foo() { - return undefined; -} +function foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md index f89f72de3c..dc833fd3db 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md @@ -20,9 +20,7 @@ function foo() { ```javascript import * as React from "react"; -function mutate() { - return undefined; -} +function mutate() {} function foo() { const $ = React.unstable_useMemoCache(1); let c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md index 751fe5ebfd..13eb752b92 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md @@ -22,9 +22,7 @@ function Component(props) { ```javascript import * as React from "react"; // @Pass runMutableRangeAnalysis -function foo() { - return undefined; -} +function foo() {} function Component(props) { const $ = React.unstable_useMemoCache(3); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md index cb1915daec..c4511530f1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md @@ -19,9 +19,7 @@ function Component(props) { ```javascript import * as React from "react"; -function foo() { - return undefined; -} +function foo() {} function Component(props) { const $ = React.unstable_useMemoCache(3); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-multiple-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-multiple-if.expect.md index ecdad5eff0..f55c93b742 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-multiple-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-multiple-if.expect.md @@ -20,9 +20,7 @@ function foo() { ## Code ```javascript -function foo() { - return undefined; -} +function foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-single-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-single-if.expect.md index 5027ce1a18..8a47245f31 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-single-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-complex-single-if.expect.md @@ -17,9 +17,7 @@ function foo() { ## Code ```javascript -function foo() { - return undefined; -} +function foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-if-else.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-if-else.expect.md index b3bb78970c..ef6a01f316 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-if-else.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-if-else.expect.md @@ -18,9 +18,7 @@ function foo() { ## Code ```javascript -function foo() { - return undefined; -} +function foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-nested-partial-phi.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-nested-partial-phi.expect.md index 08e8909c3e..e8320437f5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-nested-partial-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-nested-partial-phi.expect.md @@ -26,7 +26,6 @@ function foo(a, b, c) { } return x; } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md index f026521241..5a05f82b8d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md @@ -17,9 +17,7 @@ function Component(props) { ```javascript import * as React from "react"; -function Foo() { - return undefined; -} +function Foo() {} function Component(props) { const $ = React.unstable_useMemoCache(1); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-shadowing.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-shadowing.expect.md index 6a492777d8..f486304ece 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-shadowing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-shadowing.expect.md @@ -20,9 +20,7 @@ function Foo(cond) { ## Code ```javascript -function log() { - return undefined; -} +function log() {} function Foo(cond) { let str = ""; @@ -33,7 +31,6 @@ function Foo(cond) { } log(str); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-sibling-phis.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-sibling-phis.expect.md index f62a7ddeba..80a1187c2e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-sibling-phis.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-sibling-phis.expect.md @@ -27,9 +27,7 @@ function foo(a, b, c, d) { ## Code ```javascript -function foo(a, b, c, d) { - return undefined; -} +function foo(a, b, c, d) {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple-phi.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple-phi.expect.md index a43caacecc..aee2c34aef 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple-phi.expect.md @@ -19,9 +19,7 @@ function foo() { ## Code ```javascript -function foo() { - return undefined; -} +function foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple.expect.md index eb6839e3a9..ac778eaf49 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-simple.expect.md @@ -12,9 +12,7 @@ function foo() { ## Code ```javascript -function foo() { - return undefined; -} +function foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-single-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-single-if.expect.md index d8deb709b0..7e6ec830ec 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-single-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-single-if.expect.md @@ -16,9 +16,7 @@ function foo() { ## Code ```javascript -function foo() { - return undefined; -} +function foo() {} ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-switch.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-switch.expect.md index 3e8ad27e0b..77c8a658e9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-switch.expect.md @@ -38,7 +38,6 @@ function foo() { default: { } } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/switch-with-fallthrough.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/switch-with-fallthrough.expect.md index cecc70dd67..391d7e70e3 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/switch-with-fallthrough.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/switch-with-fallthrough.expect.md @@ -55,7 +55,6 @@ function foo(x) { default: { } } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/transitive-alias-fields.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/transitive-alias-fields.expect.md index 509d858c14..274cc5c316 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/transitive-alias-fields.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/transitive-alias-fields.expect.md @@ -31,7 +31,6 @@ function component() { q.y = p.y; mutate(q); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-args-test-binary-operator.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-args-test-binary-operator.expect.md index 8921539738..a26dfe2180 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-args-test-binary-operator.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-args-test-binary-operator.expect.md @@ -16,7 +16,6 @@ function component(a, b) { function component(a, b) { if (a > b) { } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-binary-operator.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-binary-operator.expect.md index aff3436c88..a3e5be659b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-binary-operator.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-binary-operator.expect.md @@ -20,7 +20,6 @@ function component() { const b = someOther(); if (a > b) { } - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-return-empty.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-return-empty.expect.md index ab86ad9d04..897defd568 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-return-empty.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-return-empty.expect.md @@ -18,7 +18,6 @@ function component(a) { // @inlineUseMemo function component(a) { mutate(a); - return undefined; } ``` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/while-conditional-continue.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/while-conditional-continue.expect.md index ff6e264e4a..822a79e840 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/while-conditional-continue.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/while-conditional-continue.expect.md @@ -28,7 +28,6 @@ function foo(a, b, c, d) { } d(); - return undefined; } ```