I have the same exact issue and I've tried the same exact code that you've tried so it seems to be a SwiftUI bug. I've reported it to Apple.
I also found other threads about the same issue.
Someone mentioned that the bug was resolved in iOS 17.4 Beta 2, but that wasn't the case for me. I still get the same crash + error.