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

DefaultStringInterpolation cannot be used as an argument for DynamicCallable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Environment:

      Using Xcode 10.2.1 (10E1001)

      Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
      Target: x86_64-apple-darwin18.6.0

      Description

      Introduction

      A compile-time error rises when using a string interpolation as an argument for dynamically callable func:

      public func dynamicallyCall(withArguments arguments: [String])
      

      Reproduction

      @dynamicCallable
      struct A {
      	public func dynamicallyCall(withArguments arguments: [String]) {
      		print(arguments)
      	}
      }
      
      A()("hello")
      // Output:
      // ["hello"]
      
      A()("\(1)")
      // Output:
      // error: 'inout DefaultStringInterpolation' is not convertible to 'DefaultStringInterpolation'
      // error: 'inout DefaultStringInterpolation' is not convertible to 'DefaultStringInterpolation'
      // error: 'inout DefaultStringInterpolation' is not convertible to 'DefaultStringInterpolation'
      
      

        Attachments

          Activity

            People

            • Assignee:
              Azoy Alejandro Alonso
              Reporter:
              CaptainYukinoshitaHachiman Jacky Yu
            • Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: