You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/05/11 21:12:55 UTC

[GitHub] eweiter opened a new issue #3646: Swift 4.1 issue discovered around Structs with two Strings

eweiter opened a new issue #3646: Swift 4.1 issue discovered around Structs with two Strings
URL: https://github.com/apache/incubator-openwhisk/issues/3646
 
 
   It was reported that the Swift 4.1 runtime was exhibiting a strange behavior.  The behavior in question occurs when a Struct has multiple Strings and those Strings are being initialized directly. 
   
   For instance, the following piece of code will work:
   ```
   struct Output: Codable {
       let greeting: String
       let group: String
   }
   func main(completion: (Output?, Error?) -> Void) -> Void {
       let name = "MyName"
       let result = Output(greeting: "Hello \(name)", group: "Greetings")
       print("Log greeting:\(result.greeting)")
       completion(result, nil)
   }
   ```
   However the following code will not:
   ```
   struct Output: Codable {
       let greeting: String
       let group: String
   }
   func main(completion: (Output?, Error?) -> Void) -> Void {
       let result = Output(greeting: "Hello Name", group: "bummer")
       print("Log greeting:\(result.greeting)")
       completion(result, nil)
   }
   ```
   
   It appears to be a bug within Swift itself. 
   We have discovered that if the code is compiled with the compiler flag to turn off optimizations then the compiling will work.  This compile flag is `-Xswiftc -Onone`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services