Commit Graph

2 Commits

Author SHA1 Message Date
Slava Pestov
b6381d4549 Sema: Ban forward references of captured values from 'defer' body
While 'defer' is implemented as a local function, it doesn't
behave as one. In particular, since SILGen runs it after
destroying all local bindings that appear after the 'defer'
definition, the body of a 'defer' cannot forward reference
captured bindings the way that local functions can.

Note that I had to remove a SILGen test case for an older,
related issue. The new diagnostic in Sema catches these cases
earlier.

Fixes rdar://problem/75088379.
2021-03-15 17:17:30 -04:00
Slava Pestov
4c7f0fd43b Split out 'defer' tests into their own file 2021-03-15 16:30:21 -04:00