diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts index 77b9414706..1f75d32067 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -2060,11 +2060,14 @@ function codegenPlace(cx: Context, place: Place): t.Expression | t.JSXText { } function convertIdentifier(identifier: Identifier): t.Identifier { - CompilerError.invariant(identifier.name !== null, { - reason: `Expected temporaries to be promoted to named identifiers in an earlier pass`, - loc: GeneratedSource, - description: `identifier ${identifier.id} is unnamed`, - suggestions: null, - }); + CompilerError.invariant( + identifier.name !== null && identifier.name.kind === "named", + { + reason: `Expected temporaries to be promoted to named identifiers in an earlier pass`, + loc: GeneratedSource, + description: `identifier ${identifier.id} is unnamed`, + suggestions: null, + } + ); return t.identifier(identifier.name.value); } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-try-catch-within-function-expression.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-try-catch-within-function-expression.expect.md new file mode 100644 index 0000000000..b9e0184b64 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-try-catch-within-function-expression.expect.md @@ -0,0 +1,25 @@ + +## Input + +```javascript +function Component(props) { + const callback = () => { + try { + return []; + } catch (e) { + return; + } + }; + return callback(); +} + +``` + + +## Error + +``` +[ReactForget] Invariant: Expected temporaries to be promoted to named identifiers in an earlier pass. identifier 16 is unnamed +``` + + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-try-catch-within-function-expression.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-try-catch-within-function-expression.js new file mode 100644 index 0000000000..69c394c826 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-try-catch-within-function-expression.js @@ -0,0 +1,10 @@ +function Component(props) { + const callback = () => { + try { + return []; + } catch (e) { + return; + } + }; + return callback(); +}