[SR-5641] Playgrounds don't display output for defer statements #48211
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
PlaygroundTransform
Attachment: Download
Environment
OS: macOS Sierra 10.12.6
Reproduced on Xcode 8.3.3 with Swift 3.2 and on Xcode 9 beta 5 with Swift 4.0
Additional Detail from JIRA
md5: 00c19da058773aefaeecec1ab06085f4
Issue Description:
I was trying to use the `defer` statement in a Playground, and was surprised to find that it never prints anything in the preview pane on the side. I was expecting the evaluation of the code in the `defer` statement to show up in line with the statements, even though they're executed after the last line in the function. I made a very simple playground that modifies a global variable and prints the value in the `defer` statement, and when I print the global variable after calling my function it shows the correct updated value, so the code in the `defer` statement is getting run as expected. Here's my sample code with the Playground output in comments on the side:
I was expecting something like this:
The relevant playground is attached to this issue.
The text was updated successfully, but these errors were encountered: