mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Clients should be able to handle closures without a valid `in` SourceLoc, let's avoid setting it to a recovery location. This avoids crashing in cases where we set an `in` loc that's after the closure's end loc.
18 lines
919 B
Swift
18 lines
919 B
Swift
// REQUIRES: swift_swift_parser
|
|
// REQUIRES: swift_feature_ClosureBodyMacro
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath -swift-version 5
|
|
|
|
// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -enable-experimental-feature ClosureBodyMacro
|
|
|
|
@attached(body)
|
|
macro Empty() = #externalMacro(module: "MacroDefinition", type: "EmptyBodyMacro")
|
|
|
|
// Make sure we can handle the lack of 'in' here.
|
|
_ = { @Empty x -> // expected-error {{cannot infer type of closure parameter 'x' without a type annotation}}
|
|
0 // expected-error {{expected closure result type after '->'}} expected-error {{expected 'in' after the closure signature}}
|
|
}
|
|
|
|
_ = { @Empty in }
|