dillon1000/react
Commit
Browse files Fix missing declaration invariant for "for" within try/catch
Fixes T180509722. What happened is that the logic in LeaveSSA to find declarations within for initializers wasn't working with try/catch because the initializer block gets broken up with a maybe-throw after every instruction that can throw. These maybe-throws can then get turned into gotos by PruneMaybeThrows, so LeaveSSA has to handle both cases. The new logic scans from the start of the init block until reaching the end, and creates declarations for all StoreLocals. Note that we don't yet support maybe-throw in value blocks — that's already a todo — so the change here simply allows us to compile farther until reaching that other todo. But i've double-checked the HIR and it looks correct for this case, so it should just work once we fix that todo. I've also added a comment to help us remember (and of course, we'd have to add a snap fixture too)
Changed paths3 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-repro-declaration-for-all-identifiers.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-repro-declaration-for-all-identifiers.js AddedPatch
Files changed
Rendering syntax-highlighted changes…