[swift-users] Custom operators from a module

Howard Lovatt howard.lovatt at gmail.com
Wed Sep 6 20:28:06 CDT 2017


Thanks Jordan. Turns out I had two problems:

  1. I had used ~> which is used in the library (but Xcode didn't tell me
about the redefinition).
  2. Once Xcode had decided that there was an error it wouldn't clear; but
when I quit Xcode and went back in it went away.

Thanks for your suggestion of logging a bug, reducing the problem to bug
form really helped.

  -- Howard.

On 7 September 2017 at 07:36, Howard Lovatt via swift-users <
swift-users at swift.org> wrote:

> I have a custom operator defined in a module and in my XCTest I import
> that module. In the tests the compiler says that the operator isn't
> defined. If I define the operator manually in the tests then it works.
>
> So what is going on?
>
> -- Howard.
>
> On 7 Sep 2017, at 3:45 am, Jordan Rose <jordan_rose at apple.com> wrote:
>
> It's actually the other way around: *all* operator declarations are
> exported from a module, all the time, even if the functions that implement
> them aren't. This is probably a model we should improve, but it's been that
> way since Swift 1.
>
> Jordan
>
>
> On Sep 6, 2017, at 02:08, Howard Lovatt via swift-users <
> swift-users at swift.org> wrote:
>
> Hi All,
>
> I am trying to use a custom operator imported from a module, unfortunately
> you can't add public to the operators definition and therefore it isn't
> exported from the module.
>
> I can manually redefine the operator in the module where the operator is
> used, but that isn't very satisfactory - is there a better way?
>
> Thanks in advance,
>
>   -- Howard.
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170907/a5eac7f4/attachment.html>


More information about the swift-users mailing list