Details

    • Type: Sub-task
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: None
    • Labels:
      None

      Description

      I was wondering how the function subtyping works. I don't think it does.

      let x : [@convention(c) () -> ()] = [ { print("Hello") }, { print("World") } ]
      func callAll(_ xs: [() -> ()]) {
        for f in xs {
          f()
        }
      }
      callAll(x) 

      This crashes when compiled using recent main.

      Could not cast value of type '@convention(c) () -> ()' (0x7fff88b22ba8) to '() -> ()' (0x7fff88b22d70).
      PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
      
      
      0  swift-frontend           0x00000001089cf245 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
      1  swift-frontend           0x00000001089ce238 llvm::sys::RunSignalHandlers() + 248
      2  swift-frontend           0x00000001089cf806 SignalHandler(int) + 262
      3  libsystem_platform.dylib 0x00007fff2053ad7d _sigtramp + 29
      4  libsystem_malloc.dylib   0x00007fff20336eb7 _malloc_zone_calloc + 59
      5  libsystem_c.dylib        0x00007fff20449720 abort + 120
      6  libswiftCore.dylib       0x00007fff2cbeea15 swift::fatalError(unsigned int, char const*, ...) + 149
      7  libswiftCore.dylib       0x00007fff2cbe6e87 swift::swift_dynamicCastFailure(void const*, char const*, void const*, char const*, char const*) + 71
      8  libswiftCore.dylib       0x00007fff2cbe6efa swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 106
      9  libswiftCore.dylib       0x00007fff2cbe8adc swift_dynamicCastImpl(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 4220
      10 libswiftCore.dylib       0x00007fff2c8db5f8 $ss15_arrayForceCastySayq_GSayxGr0_lF + 616
      11 libswiftCore.dylib       0x000000010b703067 $ss15_arrayForceCastySayq_GSayxGr0_lF + 18446603344255548631
      12 swift-frontend           0x0000000103dfc559 llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::Optional<llvm::StringRef>) + 1305

      Not entirely sure if this is the compiler's fault or the runtime's fault.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              theindigamer Varun Gandhi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: