Skip to content

Incorrect reconstructed type in DebugInfo when building with Embedded Swift #89257

@MaxDesiatov

Description

@MaxDesiatov

Description

No response

Reproduction

// RUN: %target-swift-frontend -g -emit-ir %s -enable-experimental-feature Embedded -enable-experimental-feature Lifetimes -wmo 2>&1 | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded
// REQUIRES: swift_feature_Lifetimes

public struct B: ~Copyable, ~Escapable { @_lifetime(immortal) init() {} }
public final class C {}

public final class K {
    var fn: ((inout B) -> C)?
    init() { self.fn = self.method }
    func method(b: inout B) -> C { C() }
}

_ = K()

You can run this command with the latest snapshot

TOOLCHAINS="$(plutil -extract CFBundleIdentifier raw ~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/Info.plist)" swiftc -g -emit-ir -enable-experimental-feature Embedded -enable-experimental-feature Lifetimes -wmo swift/test/embedded/debuginfo-noescape-closure-crash.swift

Stack dump

Abort: function getMangledName at IRGenDebugInfo.cpp:1123
Incorrect reconstructed type for $e4main1CCAA1BVzcSgD
Original type:
(bound_generic_enum_type decl="Swift.(file).Optional"
  (function_type escaping lifetime="0: copy 0"
    (input=function_params num_params=1
      (param inout
        (struct_type decl="main.(file).B@swift/test/embedded/debuginfo-noescape-closure-crash.swift:17:15")))
    (output=class_type decl="main.(file).C@swift/test/embedded/debuginfo-noescape-closure-crash.swift:18:20")))
Reconstructed type:
(bound_generic_enum_type decl="Swift.(file).Optional"
  (function_type escaping
    (input=function_params num_params=1
      (param inout
        (struct_type decl="main.(file).B@swift/test/embedded/debuginfo-noescape-closure-crash.swift:17:15")))
    (output=class_type decl="main.(file).C@swift/test/embedded/debuginfo-noescape-closure-crash.swift:18:20")))
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Pass '-Xfrontend -disable-round-trip-debug-types' to disable this assertion.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend -frontend -emit-ir swift/test/embedded/debuginfo-noescape-closure-crash.swift -target arm64-apple-macosx26.0 -Xllvm -aarch64-use-tbi -disable-objc-interop -sdk /Applications/Xcode-26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.5.sdk -no-color-diagnostics -Xcc -fno-color-diagnostics -g -debug-info-format=dwarf -dwarf-version=5 -enable-experimental-feature Embedded -enable-experimental-feature Lifetimes -empty-abi-descriptor -enable-anonymous-context-mangled-names -file-compilation-dir /Users/mdesiatov/Documents/personal/dockerfiles/workspace/github.com/swiftlang -no-auto-bridging-header-chaining -module-name main -in-process-plugin-server-path /Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 26.5 -target-sdk-name macosx26.5 -external-plugin-path /Applications/Xcode-26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -o -
1.	Apple Swift version 6.5-dev (LLVM d61b42392ef8b48, Swift 233c2bc947487c0)
2.	Compiling with effective version 5.10
3.	While evaluating request IRGenRequest(IR Generation for module main)
4.	While emitting IR SIL function "@$e4main1KCACycfc".
 for 'init()' (at swift/test/embedded/debuginfo-noescape-closure-crash.swift:22:5)
5.	Abort: function getMangledName at IRGenDebugInfo.cpp:1123
| 	Incorrect reconstructed type for $e4main1CCAA1BVzcSgD
| 	Original type:
| 	(bound_generic_enum_type decl="Swift.(file).Optional"
| 	  (function_type escaping lifetime="0: copy 0"
| 	    (input=function_params num_params=1
| 	      (param inout
| 	        (struct_type decl="main.(file).B@swift/test/embedded/debuginfo-noescape-closure-crash.swift:17:15")))
| 	    (output=class_type decl="main.(file).C@swift/test/embedded/debuginfo-noescape-closure-crash.swift:18:20")))
| 	Reconstructed type:
| 	(bound_generic_enum_type decl="Swift.(file).Optional"
| 	  (function_type escaping
| 	    (input=function_params num_params=1
| 	      (param inout
| 	        (struct_type decl="main.(file).B@swift/test/embedded/debuginfo-noescape-closure-crash.swift:17:15")))
| 	    (output=class_type decl="main.(file).C@swift/test/embedded/debuginfo-noescape-closure-crash.swift:18:20")))
| 	Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
| 	Pass '-Xfrontend -disable-round-trip-debug-types' to disable this assertion.
 #0 0x000000010a18f734 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x105e2f734)
 #1 0x000000010a18da50 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x105e2da50)
 #2 0x000000010a1901c4 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x105e301c4)
 #3 0x00000001821cf744 (/usr/lib/system/libsystem_platform.dylib+0x1804fb744)
 #4 0x00000001821c58d8 (/usr/lib/system/libsystem_pthread.dylib+0x1804f18d8)
 #5 0x00000001820cc644 (/usr/lib/system/libsystem_c.dylib+0x1803f8644)
 #6 0x000000010608af48 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x101d2af48)
 #7 0x000000010608affc (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x101d2affc)
 #8 0x0000000104b7cb94 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10081cb94)
 #9 0x0000000104b79774 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100819774)
#10 0x0000000104b7df70 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10081df70)
#11 0x0000000104b7b7fc (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10081b7fc)
#12 0x0000000104b79e38 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100819e38)
#13 0x0000000104b74760 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100814760)
#14 0x0000000104b74580 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100814580)
#15 0x0000000104bd0aa8 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100870aa8)
#16 0x0000000104bbd2b0 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10085d2b0)
#17 0x0000000104bbac38 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10085ac38)
#18 0x0000000104a535f8 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x1006f35f8)
#19 0x0000000104b6877c (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10080877c)
#20 0x0000000104bb9c00 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100859c00)
#21 0x00000001043bc6f4 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10005c6f4)
#22 0x0000000104b69800 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100809800)
#23 0x0000000104675474 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100315474)
#24 0x000000010466f49c (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10030f49c)
#25 0x000000010466ea20 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10030ea20)
#26 0x00000001046800a4 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x1003200a4)
#27 0x0000000104672750 (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x100312750)
#28 0x000000010466ffac (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10030ffac)
#29 0x000000010439917c (/Users/mdesiatov/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a.xctoolchain/usr/bin/swift-frontend+0x10003917c)
#30 0x0000000181e07e00

Expected behavior

The compiler doesn't crash. This is a regression, it didn't crash with Swift 6.3.

Environment

macOS, swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashBug: A crash, i.e., an abnormal termination of softwaredebug infoArea → compiler → IRGen: Debug information emissionembeddedEmbedded Swift

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions