Dangling `}` at end of line: Build fine, SwiftUI preview fail: Compiling failed: consecutive statements on a line must be separated by ';'

Xcode Version 13.0 beta 4 (13A5201i)

No compile error but SwiftUI preview crash

import SwiftUI

struct RedactedDemo: View {
    var body: some View {
        VStack {
            Text("Five Stars")
                .font(.title2)

            Text("This")
            Text("is")
            Text("redacted!")
        }
        // 👇👇 } at the end is not allowed? Build fine, preview crash
        .redacted(reason: .placeholder)    }
}

struct RedactedDemo_Previews: PreviewProvider {
    static var previews: some View {
        RedactedDemo()
    }
}

(The dangling } is result of pasting code into existing code.)

This is clearly a bug. Report it to https://bugs.swift.org/

This code does not crash the preview for me.

I'm using Xcode Version 13.0 beta 4 (13A5201i)

What version are you using?

I cannot create bug report:

We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file.

Could this be caused by SwiftUI preview and not a bug with the Swift compiler (since build is okay)? I'm guessing SwiftUI preview might be doing some code gen and the dangling } mess thing up there? Nevertheless I think the compiler should be able to deal with this odd formatting.

I'm using Xcode Version 13.0 beta 4 (13A5201i)

Ah yeah, I missed that part. Crashes for me on 13b4 too.

It might be the use of emojis that blocked you from creating the issue. At least that's what stopped me last time.

You are right!

https://bugs.swift.org/browse/SR-15029

Terms of Service

Privacy Policy

Cookie Policy