Uploaded image for project: 'Swift'
  1. Swift
  2. SR-9376

Private CodingKeys in another file messes up Codable synthesis

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Environment:

      Tested with Xcode Version 10.1 (10B61) included toolchain and the latest master (2018-11-28a)

      Description

      This traps the compiler when using `incremental` compilation mode but not when using `whole module` mode (see attached sample project for easy testing):

      Property.swift

      struct Property: Decodable {
          var key: String
      }
      

      Property+Codable.swift

      extension Property {
          private enum CodingKeys: String, CodingKey {
              case key
          }
      }
      

      with the result:

      Global is external, but doesn't have external or weak linkage!
      %swift.type* @"$S14CodableCrasher8PropertyV10CodingKeys33_1AC7B054C26C4327D88753EB7D2E403CLLON"
      <unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
      <unknown>:0: note: Broken module found, compilation aborted!
      0  swift                    0x000000010542f59a PrintStackTraceSignalHandler(void*) + 42
      1  swift                    0x000000010542ed4e SignalHandler(int) + 302
      2  libsystem_platform.dylib 0x00007fff592edb3d _sigtramp + 29
      3  libsystem_platform.dylib 0x00007ffeee5cad20 _sigtramp + 2502808064
      4  libsystem_c.dylib        0x00007fff591ac1c9 abort + 127
      5  swift                    0x00000001016b4a67 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_1::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 519
      6  swift                    0x00000001053e31c8 llvm::report_fatal_error(llvm::Twine const&, bool) + 280
      7  swift                    0x00000001053e30ab llvm::report_fatal_error(char const*, bool) + 43
      8  swift                    0x00000001053aa6ec (anonymous namespace)::VerifierLegacyPass::doFinalization(llvm::Module&) + 204
      9  swift                    0x0000000105350763 llvm::FPPassManager::doFinalization(llvm::Module&) + 83
      10 swift                    0x0000000105355b57 llvm::legacy::FunctionPassManagerImpl::doFinalization(llvm::Module&) + 71
      11 swift                    0x000000010187b1b5 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine*, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter*) + 4533
      12 swift                    0x00000001016c1242 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 49170
      13 swift                    0x00000001016b1d35 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
      14 swift                    0x0000000101657965 main + 1349
      15 libdyld.dylib            0x00007fff5910408d start + 1
      Stack dump:
      0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/tkrajacic/Downloads/CodableCrasher/CodableCrasher/Property.swift /Users/tkrajacic/Downloads/CodableCrasher/CodableCrasher/Property+Codable.swift /Users/tkrajacic/Downloads/CodableCrasher/CodableCrasher/AppDelegate.swift -emit-module-path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/Objects-normal/x86_64/Property~partial.swiftmodule -emit-module-doc-path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/Objects-normal/x86_64/Property~partial.swiftdoc -serialize-diagnostics-path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/Objects-normal/x86_64/Property.dia -emit-dependencies-path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/Objects-normal/x86_64/Property.d -emit-reference-dependencies-path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/Objects-normal/x86_64/Property.swiftdeps -target x86_64-apple-macosx10.14 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Products/Debug -F /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Products/Debug -enable-testing -g -module-cache-path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/CodableCrasher-generated-files.hmap -Xcc -I/Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/CodableCrasher-own-target-headers.hmap -Xcc -I/Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/CodableCrasher-all-target-headers.hmap -Xcc -iquote -Xcc /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/CodableCrasher-project-headers.hmap -Xcc -I/Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Products/Debug/include -Xcc -I/Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/DerivedSources/x86_64 -Xcc -I/Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/tkrajacic/Downloads/CodableCrasher -module-name CodableCrasher -o /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Build/Intermediates.noindex/CodableCrasher.build/Debug/CodableCrasher.build/Objects-normal/x86_64/Property.o -index-store-path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/CodableCrasher-efdmtzdcpqqlnnhkijqdnqchqgjg/Index/DataStore -index-system-modules 
      error: Abort trap: 6

       

      This only happens when the conformance is in a separate file.

       

      Possibly related to https://bugs.swift.org/browse/SR-4370 ?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tkrajacic Thomas Krajacic
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: