<div dir="ltr">You may want to add the specific error to your proposal.  <div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>error: member operator &#39;•|&#39; must have at least one argument of type &#39;NonEmptyArray&lt;Element&gt;&#39;</b></span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>        public static func •|&lt;Element&gt;(lhs: Element, rhs: [Element]) -&gt; NonEmptyArray&lt;Element&gt;</b></span></p></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 10, 2016 at 11:49 PM Derrick Ho &lt;<a href="mailto:wh1pch81n@gmail.com">wh1pch81n@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">I placed he code you wrote in the proposal in playgrounds and it works perfectly.  (reproduced below). Overloading operators used to only happen globally and since swift 3 they allowed you to put then inside the class/struct<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><pre style="box-sizing:border-box;font-family:consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="box-sizing:border-box;font-family:consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">public struct NonEmptyArray&lt;Element&gt; {

    fileprivate var elements: Array&lt;Element&gt;

    fileprivate init(array: [Element]) {
        self.elements = array
    }
}

//Overload 1
public func •|&lt;Element&gt;(lhs: Element, rhs: [Element]) -&gt; NonEmptyArray&lt;Element&gt; {
    return NonEmptyArray(array: rhs + [lhs])
}

//Overload 2
public func •|&lt;Element&gt;(lhs: Element, rhs:  NonEmptyArray&lt;Element&gt;) -&gt; NonEmptyArray&lt;Element&gt; {
    return NonEmptyArray(array: [lhs] + rhs.elements)
}

//Overload 3
public func •|&lt;Element&gt;(lhs: NonEmptyArray&lt;Element&gt;, rhs: NonEmptyArray&lt;Element&gt;) -&gt; NonEmptyArray&lt;Element&gt; {
    return NonEmptyArray(array: lhs.elements + rhs.elements)
}</code></pre></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">However, as you have detailed when you place those overloads inside the struct/class, it does not work.  Actually I get an error that says that at least ONE of the arguments needs to be the same type.  In this case one of them needs to be NonEmptyArray&lt;Element&gt;. It is clearly not a bug, but rather a swift rule.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">My recommendation is to just keep those overloads as global.  Is there a particular advantage to putting them inside the struct/class?<br class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div></div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Sat, Dec 10, 2016 at 8:36 PM David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Dec 10, 2016, at 5:29 PM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_8139447927534648323m_-1969521834013891672Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><br class="m_8139447927534648323m_-1969521834013891672Apple-interchange-newline gmail_msg">On Dec 10, 2016, at 4:54 PM, Tommaso Piazza via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_8139447927534648323m_-1969521834013891672Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div style="background-color:rgb(255,255,255);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;font-size:16px" class="gmail_msg"><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg">Hello,</div><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg"><br class="gmail_msg"></div><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg">I have written a small proposal that would allow overloads of operators in structs/classes non only based on the types of the operands but on the return type as well.</div><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg"><br class="gmail_msg"></div><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg">Please let me know you thoughts,</div><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg">/Tommaso</div><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg"><br class="gmail_msg"></div><div dir="ltr" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3640" class="gmail_msg"><a href="https://github.com/blender/swift-evolution/blob/proposal/overloads-return-type/NNNN-allow-operator-overloads-in-structs-or-classes-based-on-return-type.md" id="m_8139447927534648323m_-1969521834013891672yui_3_16_0_ym19_1_1481417388759_3639" class="gmail_msg" target="_blank">https://github.com/blender/swift-evolution/blob/proposal/overloads-return-type/NNNN-allow-operator-overloads-in-structs-or-classes-based-on-return-type.md</a><br class="gmail_msg"></div></div></div></div></blockquote><br class="gmail_msg"></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg">That seems like a bug to me… Dunno, maybe it’s intentional and I’m just not aware of the reasoning.</div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">Actually, since the error message correctly parses the code, it probably <i class="gmail_msg">is</i> intentional… I don’t see the problem, myself, but I guess I’d have to know why it’s considered an error before judging whether I think we should remove the restriction.</div><div class="gmail_msg"><br class="gmail_msg"></div>- Dave Sweeris</div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div></blockquote></div>