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")

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

struct RedactedDemo_Previews: PreviewProvider {
    static var previews: some View {

(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!


Terms of Service

Privacy Policy

Cookie Policy