|
| 1 | + |
| 2 | +## Input |
| 3 | + |
| 4 | +```javascript |
| 5 | +function Component({a, b, c}) { |
| 6 | + // This is an object version of array-access-assignment.js |
| 7 | + // Meant to confirm that object expressions and PropertyStore/PropertyLoad with strings |
| 8 | + // works equivalently to array expressions and property accesses with numeric indices |
| 9 | + const x = {zero: a}; |
| 10 | + const y = {zero: null, one: b}; |
| 11 | + const z = {zero: {}, one: {}, two: {zero: c}}; |
| 12 | + x.zero = y.one; |
| 13 | + z.zero.zero = x.zero; |
| 14 | + return {zero: x, one: z}; |
| 15 | +} |
| 16 | + |
| 17 | +export const FIXTURE_ENTRYPOINT = { |
| 18 | + fn: Component, |
| 19 | + params: [{a: 1, b: 20, c: 300}], |
| 20 | + sequentialRenders: [ |
| 21 | + {a: 2, b: 20, c: 300}, |
| 22 | + {a: 3, b: 20, c: 300}, |
| 23 | + {a: 3, b: 21, c: 300}, |
| 24 | + {a: 3, b: 22, c: 300}, |
| 25 | + {a: 3, b: 22, c: 301}, |
| 26 | + ], |
| 27 | +}; |
| 28 | + |
| 29 | +``` |
| 30 | + |
| 31 | +## Code |
| 32 | + |
| 33 | +```javascript |
| 34 | +import { c as _c } from "react/compiler-runtime"; |
| 35 | +function Component(t0) { |
| 36 | + const $ = _c(10); |
| 37 | + const { a, b, c } = t0; |
| 38 | + let t1; |
| 39 | + if ($[0] !== a || $[1] !== b || $[2] !== c) { |
| 40 | + const x = { zero: a }; |
| 41 | + let t2; |
| 42 | + if ($[4] !== b) { |
| 43 | + t2 = { zero: null, one: b }; |
| 44 | + $[4] = b; |
| 45 | + $[5] = t2; |
| 46 | + } else { |
| 47 | + t2 = $[5]; |
| 48 | + } |
| 49 | + const y = t2; |
| 50 | + let t3; |
| 51 | + let t4; |
| 52 | + if ($[6] === Symbol.for("react.memo_cache_sentinel")) { |
| 53 | + t3 = {}; |
| 54 | + t4 = {}; |
| 55 | + $[6] = t3; |
| 56 | + $[7] = t4; |
| 57 | + } else { |
| 58 | + t3 = $[6]; |
| 59 | + t4 = $[7]; |
| 60 | + } |
| 61 | + let t5; |
| 62 | + if ($[8] !== c) { |
| 63 | + t5 = { zero: c }; |
| 64 | + $[8] = c; |
| 65 | + $[9] = t5; |
| 66 | + } else { |
| 67 | + t5 = $[9]; |
| 68 | + } |
| 69 | + const z = { zero: t3, one: t4, two: t5 }; |
| 70 | + x.zero = y.one; |
| 71 | + z.zero.zero = x.zero; |
| 72 | + t1 = { zero: x, one: z }; |
| 73 | + $[0] = a; |
| 74 | + $[1] = b; |
| 75 | + $[2] = c; |
| 76 | + $[3] = t1; |
| 77 | + } else { |
| 78 | + t1 = $[3]; |
| 79 | + } |
| 80 | + return t1; |
| 81 | +} |
| 82 | + |
| 83 | +export const FIXTURE_ENTRYPOINT = { |
| 84 | + fn: Component, |
| 85 | + params: [{ a: 1, b: 20, c: 300 }], |
| 86 | + sequentialRenders: [ |
| 87 | + { a: 2, b: 20, c: 300 }, |
| 88 | + { a: 3, b: 20, c: 300 }, |
| 89 | + { a: 3, b: 21, c: 300 }, |
| 90 | + { a: 3, b: 22, c: 300 }, |
| 91 | + { a: 3, b: 22, c: 301 }, |
| 92 | + ], |
| 93 | +}; |
| 94 | + |
| 95 | +``` |
| 96 | + |
| 97 | +### Eval output |
| 98 | +(kind: ok) {"zero":{"zero":20},"one":{"zero":{"zero":20},"one":{},"two":{"zero":300}}} |
| 99 | +{"zero":{"zero":20},"one":{"zero":{"zero":20},"one":{},"two":{"zero":300}}} |
| 100 | +{"zero":{"zero":21},"one":{"zero":{"zero":21},"one":{},"two":{"zero":300}}} |
| 101 | +{"zero":{"zero":22},"one":{"zero":{"zero":22},"one":{},"two":{"zero":300}}} |
| 102 | +{"zero":{"zero":22},"one":{"zero":{"zero":22},"one":{},"two":{"zero":301}}} |
0 commit comments