Files
swift-mirror/test/Macros/macro_expand_body_closure.swift
Hamish Knight b83cf1eaa5 [Parse] Avoid setting closure in SourceLoc if missing
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.
2025-10-13 15:34:57 +01:00

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 }