Files
swift-mirror/test/Parse/toplevel_library_invalid.swift
John McCall bc3b47b98a Infer the return type of a closure to be () if it contains no
return statements, or a return statement with no operand.

Also, fix a special-case diagnostic about converting a return
expression to (1) only apply to converting the actual return
expression, not an arbitrary sub-expression, and (2) use the
actual operand and return types, not the drilled-down types
that caused the failure.

Swift SVN r30420
2015-07-20 21:52:18 +00:00

16 lines
827 B
Swift

// RUN: %target-parse-verify-swift -parse-as-library
let x = 42
x + x; // expected-error {{expressions are not allowed at the top level}}
x + x; // expected-error {{expressions are not allowed at the top level}}
// Make sure we don't crash on closures at the top level
({ }) // expected-error {{expressions are not allowed at the top level}} expected-error{{expression resolves to an unused function}}
({ 5 }()) // expected-error {{expressions are not allowed at the top level}}
// FIXME: Too many errors for this.
for i // expected-error 2 {{expected ';' in 'for' statement}}
// expected-error @-1{{use of unresolved identifier 'i'}}
// expected-error @+3{{expected '{' in 'for' statement}}
// expected-error @+2{{expected condition in 'for' statement}}
// expected-error @+1{{expected expression}}