diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/repro-fbt-param-nested-fbt-jsx.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/repro-fbt-param-nested-fbt-jsx.expect.md new file mode 100644 index 0000000000..10a2a9ae13 --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/repro-fbt-param-nested-fbt-jsx.expect.md @@ -0,0 +1,128 @@ + +## Input + +```javascript +import fbt from 'fbt'; +import {Stringify, identity} from 'shared-runtime'; + +/** + * MemoizeFbtAndMacroOperands needs to account for nested fbt calls. + * Expected fixture `fbt-param-call-arguments` to succeed but it failed with error: + * /fbt-param-call-arguments.ts: Line 19 Column 11: fbt: unsupported babel node: Identifier + * --- + * t3 + * --- + */ +function Component({firstname, lastname}) { + 'use memo'; + return ( +
+ {fbt( + [ + 'Name: ', + fbt.param('firstname', ), + ', ', + fbt.param( + 'lastname', + identity( + fbt( + '(inner)' + + fbt.param('lastname', ), + 'Inner fbt value' + ) + ) + ), + ], + 'Name' + )} +
+ ); +} + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{firstname: 'first', lastname: 'last'}], + sequentialRenders: [{firstname: 'first', lastname: 'last'}], +}; + +``` + +## Code + +```javascript +import { c as _c } from "react/compiler-runtime"; +import fbt from "fbt"; +import { Stringify, identity } from "shared-runtime"; + +/** + * MemoizeFbtAndMacroOperands needs to account for nested fbt calls. + * Expected fixture `fbt-param-call-arguments` to succeed but it failed with error: + * /fbt-param-call-arguments.ts: Line 19 Column 11: fbt: unsupported babel node: Identifier + * --- + * t3 + * --- + */ +function Component(t0) { + "use memo"; + const $ = _c(9); + const { firstname, lastname } = t0; + let t1; + if ($[0] !== firstname || $[1] !== lastname) { + let t2; + if ($[3] !== firstname) { + t2 = ; + $[3] = firstname; + $[4] = t2; + } else { + t2 = $[4]; + } + let t3; + if ($[5] !== lastname) { + t3 = ; + $[5] = lastname; + $[6] = t3; + } else { + t3 = $[6]; + } + t1 = fbt._( + "Name: {firstname}, {lastname}", + [ + fbt._param("firstname", t2), + fbt._param( + "lastname", + identity( + fbt._("(inner){lastname}", [fbt._param("lastname", t3)], { + hk: "1Kdxyo", + }), + ), + ), + ], + { hk: "3AiIf8" }, + ); + $[0] = firstname; + $[1] = lastname; + $[2] = t1; + } else { + t1 = $[2]; + } + let t2; + if ($[7] !== t1) { + t2 =
{t1}
; + $[7] = t1; + $[8] = t2; + } else { + t2 = $[8]; + } + return t2; +} + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ firstname: "first", lastname: "last" }], + sequentialRenders: [{ firstname: "first", lastname: "last" }], +}; + +``` + +### Eval output +(kind: ok)
Name:
{"name":"first"}
, (inner)
{"name":"last"}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/repro-fbt-param-nested-fbt-jsx.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/repro-fbt-param-nested-fbt-jsx.js new file mode 100644 index 0000000000..07efb4e03a --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/repro-fbt-param-nested-fbt-jsx.js @@ -0,0 +1,42 @@ +import fbt from 'fbt'; +import {Stringify, identity} from 'shared-runtime'; + +/** + * MemoizeFbtAndMacroOperands needs to account for nested fbt calls. + * Expected fixture `fbt-param-call-arguments` to succeed but it failed with error: + * /fbt-param-call-arguments.ts: Line 19 Column 11: fbt: unsupported babel node: Identifier + * --- + * t3 + * --- + */ +function Component({firstname, lastname}) { + 'use memo'; + return ( +
+ {fbt( + [ + 'Name: ', + fbt.param('firstname', ), + ', ', + fbt.param( + 'lastname', + identity( + fbt( + '(inner)' + + fbt.param('lastname', ), + 'Inner fbt value' + ) + ) + ), + ], + 'Name' + )} +
+ ); +} + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{firstname: 'first', lastname: 'last'}], + sequentialRenders: [{firstname: 'first', lastname: 'last'}], +};