Files
swift-mirror/test/Parse/toplevel_library_invalid.swift
2021-01-15 22:14:56 +09:00

16 lines
867 B
Swift

// RUN: %target-typecheck-verify-swift -parse-as-library
let x = 42
x + x; // expected-error {{expressions are not allowed at the top level}} expected-warning {{result of operator '+' is unused}}
x + x; // expected-error {{expressions are not allowed at the top level}} expected-warning {{result of operator '+' is unused}}
// Make sure we don't crash on closures at the top level
({ }) // expected-error {{expressions are not allowed at the top level}} expected-error{{function is unused}}
({ 5 }()) // expected-error {{expressions are not allowed at the top level}}
// expected-warning @-1 {{result of call to closure returning 'Int' is unused}}
// expected-error @+3 {{expected 'in' after for-each pattern}}
// expected-error @+2 {{expected Sequence expression for for-each loop}}
// expected-error @+1 {{expected '{' to start the body of for-each loop}}
for i