Files
swift-mirror/test/Parse/guard-top-level.swift
Jordan Rose 4cdac3fc4c Don't add variables declared in 'guard let' to a SourceFile's Decls.
These variables really are local variables -- they have have a
TopLevelCodeDecl as their DeclContext rather than the SourceFile.
Treating them as global variables caused crashes in serialization.

We need an overhaul of top-level variables in script files anyway
(see rdar://problem/20992489&21628526), but this fixes the immediate
issue.

rdar://problem/21928533

Swift SVN r30519
2015-07-23 00:55:36 +00:00

10 lines
140 B
Swift

// RUN: %target-parse-verify-swift
let a: Int? = 1
guard let b = a else {
}
func foo() {} // to interrupt the TopLevelCodeDecl
let c = b