mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
Optimized code stores no temporary for a deconstruction element that is used only once after the deconstruction. MatchAssignments handled that for trailing elements, but a nested deconstruction copies the inner element to a temporary, so the elements preceding it are also left without an assignment; their external load then violated the DeconstructInstruction invariant that all pattern variable loads are descendants of the instruction. The forwarding fixup now covers all unassigned elements and inserts in pattern order, because the statement and expression builders pair pattern variables with assignments positionally. This also fixes the nested tuple deconstruction crash reported in #3388. Also unwrap the address of the tested operand in VisitDeconstructInstruction: deconstructing a struct passes the receiver by reference, which was emitted as an invalid cast, 'var (x, y) = (S)(ref s);', even without nesting. Fixes #3388. Assisted-by: Claude:claude-fable-5:Claude Codepull/3933/head
4 changed files with 166 additions and 15 deletions
Loading…
Reference in new issue