Files
swift-mirror/test/Sema/diag_defer_block_end.swift
Slava Pestov 2ef101c815 Sema: Don't add local functions to TC.definedFunctions
Instead, check them and their error handling right away.

In addition to fixing the crash in the radar, this also causes
us to emit unused variable warnings in functions containing
local functions.

Eventually, TC.definedFunctions should go away altogether.

Fixes <rdar://problem/53956342>.
2019-08-07 00:37:21 -04:00

24 lines
517 B
Swift

// RUN: %target-typecheck-verify-swift
let x = 1
let y = 2
if (x > y) {
defer { // expected-warning {{'defer' statement at end of scope always executes immediately}}{{5-10=do}}
print("not so useful defer stmt.")
}
}
func sr7307(_ value: Bool) {
let negated = !value
defer { // expected-warning {{'defer' statement at end of scope always executes immediately}}{{5-10=do}}
print("negated value is \(negated)")
}
}
sr7307(true)
defer { // No note
print("end of program.")
}