[SR-5242] #sourceLocation rejected at end of extension/struct/class/enum declarations #47817
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
parser
Area → compiler: The legacy C++ parser
regression
swift 4.0
Environment
Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
md5: 54dbda83eea091fe20ef30129991e0c7
Issue Description:
In generated Swift code, I use the
#sourceLocation
directive to map source lines to the corresponding location in my input files. Because the mapping may not exactly correspond to the syntactic structure of Swift, I expect to be able to use the directive at any position in Swift code.In Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8), the compiler produces an error when a
#sourceLocation
directive appears before the closing brace of an extension, struct, class, enum, or protocol declaration.For example, the following code used to compile in Swift 3.2:
The Swift 4 compiler, however, produces the following diagnostic:
I can work around the error by adding a dummy member after the
#sourceLocation
directive, but that is not always a viable option in generated code.The text was updated successfully, but these errors were encountered: