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

SE-0044 import as subscript does not work

    XMLWordPrintable

    Details

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

      Tested with Xcode 10.2 beta (10P82s).

      Description

      The ”import as subscript” from SE-0044 Import as member does not work. Example:

      // CFile.h:
      
      typedef struct Point3D {
          float x;
          float y;
          float z;
      } Point3D;
      
      float Point3DGetPointAtIndex(Point3D point, int idx)
      __attribute__((swift_name("getter:Point3D.subscript(self:_:)")));
      
      // main.swift:
      
      let p = Point3D()
      let x = p[0];
      // Error: Value of type 'Point3D' has no subscripts
      
      let y = Point3DGetPointAtIndex(p, 0)
      // 'Point3DGetPointAtIndex' has been replaced by property 'Point3D.subscript'
      

      Apparently, the function is imported as a property named "subscript."

      Related discussion in the Swift forum: Import C functions as subscript methods (follow-up).

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              martin Martin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: