|
| 1 | + |
| 2 | +## Input |
| 3 | + |
| 4 | +```javascript |
| 5 | +import {identity} from 'shared-runtime'; |
| 6 | + |
| 7 | +/** |
| 8 | + * Evaluator failure: |
| 9 | + * Found differences in evaluator results |
| 10 | + * Non-forget (expected): |
| 11 | + * (kind: ok) {} |
| 12 | + * [[ (exception in render) TypeError: Cannot read properties of null (reading 'title_text') ]] |
| 13 | + * Forget: |
| 14 | + * (kind: ok) {} |
| 15 | + * {} |
| 16 | + */ |
| 17 | +/** |
| 18 | + * Very contrived text fixture showing that it's technically incorrect to merge |
| 19 | + * a conditional dependency (e.g. dep.path in `cond ? dep.path : ...`) and an |
| 20 | + * unconditionally evaluated optional chain (`dep?.path`). |
| 21 | + * |
| 22 | + * |
| 23 | + * when screen is non-null, useFoo returns { title: null } or "(not null)" |
| 24 | + * when screen is null, useFoo throws |
| 25 | + */ |
| 26 | +function useFoo({screen}: {screen: null | undefined | {title_text: null}}) { |
| 27 | + return screen?.title_text != null |
| 28 | + ? '(not null)' |
| 29 | + : identity({title: screen.title_text}); |
| 30 | +} |
| 31 | +export const FIXTURE_ENTRYPOINT = { |
| 32 | + fn: useFoo, |
| 33 | + params: [{screen: null}], |
| 34 | + sequentialRenders: [{screen: {title_bar: undefined}}, {screen: null}], |
| 35 | +}; |
| 36 | + |
| 37 | +``` |
| 38 | +
|
| 39 | +## Code |
| 40 | +
|
| 41 | +```javascript |
| 42 | +import { c as _c } from "react/compiler-runtime"; |
| 43 | +import { identity } from "shared-runtime"; |
| 44 | + |
| 45 | +/** |
| 46 | + * Evaluator failure: |
| 47 | + * Found differences in evaluator results |
| 48 | + * Non-forget (expected): |
| 49 | + * (kind: ok) {} |
| 50 | + * [[ (exception in render) TypeError: Cannot read properties of null (reading 'title_text') ]] |
| 51 | + * Forget: |
| 52 | + * (kind: ok) {} |
| 53 | + * {} |
| 54 | + */ |
| 55 | +/** |
| 56 | + * Very contrived text fixture showing that it's technically incorrect to merge |
| 57 | + * a conditional dependency (e.g. dep.path in `cond ? dep.path : ...`) and an |
| 58 | + * unconditionally evaluated optional chain (`dep?.path`). |
| 59 | + * |
| 60 | + * |
| 61 | + * when screen is non-null, useFoo returns { title: null } or "(not null)" |
| 62 | + * when screen is null, useFoo throws |
| 63 | + */ |
| 64 | +function useFoo(t0) { |
| 65 | + const $ = _c(2); |
| 66 | + const { screen } = t0; |
| 67 | + let t1; |
| 68 | + if ($[0] !== screen?.title_text) { |
| 69 | + t1 = |
| 70 | + screen?.title_text != null |
| 71 | + ? "(not null)" |
| 72 | + : identity({ title: screen.title_text }); |
| 73 | + $[0] = screen?.title_text; |
| 74 | + $[1] = t1; |
| 75 | + } else { |
| 76 | + t1 = $[1]; |
| 77 | + } |
| 78 | + return t1; |
| 79 | +} |
| 80 | + |
| 81 | +export const FIXTURE_ENTRYPOINT = { |
| 82 | + fn: useFoo, |
| 83 | + params: [{ screen: null }], |
| 84 | + sequentialRenders: [{ screen: { title_bar: undefined } }, { screen: null }], |
| 85 | +}; |
| 86 | + |
| 87 | +``` |
| 88 | + |
0 commit comments