Null Coalescing Operator kills the compiler?

We have been migrating our App from Swift 2 to 3 and with all the bug fixing etc we noticed the compiler was hanging and never finishing. After a great deal of time pull in the project apart to narrow down the problem we have found that Null Coalescing Operator when used in certain situations will cause the compiler to hang...


This will cause the compiler to hang


let values = "\(customer.name),"
            + "\(customer.telephone),"
            + "\(customer.email),"
            + "\(customer.deliveryAddress1),"
            + "\(customer.deliveryTown),"
            + "\(customer.deliveryPostcode ?? ""),"
            + "\(customer.deliveryCountryCode)"


where as this will not


let values = "\(customer.name),"
            + "\(customer.telephone),"
            + "\(customer.email),
            + "\(customer.deliveryAddress1),"
            + "\(customer.deliveryTown),"
            + "\(customer.deliveryPostcode != nil ? customer.deliveryPostcode : ""),"
            + "\(customer.deliveryCountryCode)"


I hope this will cause the compiler team to take a look and hopefully fix this issue.

It also seems to struggle with type inference...


Sooooo slow...


if let newCustomer: NewCustomer = find(customerID: customerID) {
            let parameters : [String : Any] = [
                "Name": newCustomer.name,
              
                "RegNo": newCustomer.regNo,
                "VatNo": newCustomer.vatNo ?? "",
              
                "Telephone": newCustomer.telephone,
                "Email": newCustomer.email,
                "Website": newCustomer.website ?? "",
              
                "ContactName": newCustomer.contactName,
                "ContactPosition": newCustomer.contactPosition,
                "ContactTelephone": newCustomer.contactTelephone,
              
                "InvoiceAddress1": newCustomer.invoiceAddress1,
                "InvoiceAddress2": newCustomer.invoiceAddress2 ?? "",
                "InvoiceAddress3": newCustomer.invoiceAddress3 ?? "",
                "InvoiceTown": newCustomer.invoiceTown,
                "InvoiceCounty": newCustomer.invoiceCounty ?? "",
                "InvoicePostcode": newCustomer.invoicePostcode ?? "",
                "InvoiceCountryCode": newCustomer.invoiceCountryCode,
              
                "DeliveryAddress1": newCustomer.deliveryAddress1,
                "DeliveryAddress2": newCustomer.deliveryAddress2 ?? "",
                "DeliveryAddress3": newCustomer.deliveryAddress3 ?? "",
                "DeliveryTown": newCustomer.deliveryTown,
                "DeliveryCounty": newCustomer.deliveryCounty ?? "",
                "DeliveryPostcode": newCustomer.deliveryPostcode ?? "",
                "DeliveryCountryCode": newCustomer.deliveryCountryCode,
  
                "SalesmanAreaCode": newCustomer.salesmanAreaCode,
                "PriceCategoryID": newCustomer.priceCategoryID,
                "DiscountPercentage": newCustomer.discountPercentage,
                "PaymentTermsID": newCustomer.paymentTermsID
            ]
}


Instant...


if let newCustomer: NewCustomer = find(customerID: customerID) {
            let parameters : [String : Any] = [
                "Name": newCustomer.name as String,
               
                "RegNo": newCustomer.regNo as String,
                "VatNo": newCustomer.vatNo ?? "" as String,
               
                "Telephone": newCustomer.telephone as String,
                "Email": newCustomer.email  as String,
                "Website": newCustomer.website ?? "" as String,
               
                "ContactName": newCustomer.contactName as String,
                "ContactPosition": newCustomer.contactPosition as String,
                "ContactTelephone": newCustomer.contactTelephone as String,
               
                "InvoiceAddress1": newCustomer.invoiceAddress1 as String,
                "InvoiceAddress2": newCustomer.invoiceAddress2 ?? "" as String,
                "InvoiceAddress3": newCustomer.invoiceAddress3 ?? "" as String,
                "InvoiceTown": newCustomer.invoiceTown as String,
                "InvoiceCounty": newCustomer.invoiceCounty ?? "" as String,
                "InvoicePostcode": newCustomer.invoicePostcode ?? "" as String,
                "InvoiceCountryCode": newCustomer.invoiceCountryCode as String,
               
                "DeliveryAddress1": newCustomer.deliveryAddress1 as String,
                "DeliveryAddress2": newCustomer.deliveryAddress2 ?? "" as String,
                "DeliveryAddress3": newCustomer.deliveryAddress3 ?? "" as String,
                "DeliveryTown": newCustomer.deliveryTown as String,
                "DeliveryCounty": newCustomer.deliveryCounty ?? "" as String,
                "DeliveryPostcode": newCustomer.deliveryPostcode ?? "" as String,
                "DeliveryCountryCode": newCustomer.deliveryCountryCode as String,
   
                "SalesmanAreaCode": newCustomer.salesmanAreaCode as String,
                "PriceCategoryID": newCustomer.priceCategoryID as Int,
                "DiscountPercentage": newCustomer.discountPercentage as Double,
                "PaymentTermsID": newCustomer.paymentTermsID as Int
            ]
}

You should file a bug report using the report bug link at the bottom of the page.

These groups aren't monitored for bug reports.

I suppose deliveryPostCode is an optional in your code ?


Then the line should unwrap :


+ "\(customer.deliveryPostcode != nil ? customer.deliveryPostcode! : ""),"

Null Coalescing Operator kills the compiler?
 
 
Q