Help with SR-1052: Handling generic return values

Could someone who knows the generics system better than I give me a pointer
for my question in [SR-1052] Implement SE-0047 - Defaulting non-Void functions so they warn on unused results · Issue #43664 · apple/swift · GitHub (support for
@discardableResult attribute)?

Question:

I'm starting to look at Part 5 (having the compiler use the new attr). What
I have so far appears to be working with the exception of signatures like
this:

public mutating func withMutableCharacters<R>(_ body: (inout CharacterView)
-> R) -> R

where the return type is generic.

For regular functions, I can skip the warning if the result type in the
decl is Void.

Any ideas on how to tell if a call to a generic function like
withMutableCharacters has a return type of Void in context?

My branch with the work for Part 5 so far is at
https://github.com/tanadeau/swift/commits/sr-1052-use-attr\.

···

--
Trent Nadeau

Can anyone help me with this?

···

On Fri, Apr 22, 2016 at 6:43 PM, Trent Nadeau <tanadeau@gmail.com> wrote:

Could someone who knows the generics system better than I give me a
pointer for my question in [SR-1052] Implement SE-0047 - Defaulting non-Void functions so they warn on unused results · Issue #43664 · apple/swift · GitHub (support
for @discardableResult attribute)?

Question:

I'm starting to look at Part 5 (having the compiler use the new attr).
What I have so far appears to be working with the exception of signatures
like this:

public mutating func withMutableCharacters<R>(_ body: (inout
CharacterView) -> R) -> R

where the return type is generic.

For regular functions, I can skip the warning if the result type in the
decl is Void.

Any ideas on how to tell if a call to a generic function like
withMutableCharacters has a return type of Void in context?

My branch with the work for Part 5 so far is at
https://github.com/tanadeau/swift/commits/sr-1052-use-attr\.

--
Trent Nadeau

--
Trent Nadeau

+Doug, Joe

···

On Tue, May 3, 2016 at 6:28 PM, Trent Nadeau via swift-dev <swift-dev@swift.org> wrote:

Can anyone help me with this?

On Fri, Apr 22, 2016 at 6:43 PM, Trent Nadeau <tanadeau@gmail.com> wrote:

Could someone who knows the generics system better than I give me a
pointer for my question in [SR-1052] Implement SE-0047 - Defaulting non-Void functions so they warn on unused results · Issue #43664 · apple/swift · GitHub (support
for @discardableResult attribute)?

Question:

I'm starting to look at Part 5 (having the compiler use the new attr).
What I have so far appears to be working with the exception of signatures
like this:

public mutating func withMutableCharacters<R>(_ body: (inout
CharacterView) -> R) -> R

where the return type is generic.

For regular functions, I can skip the warning if the result type in the
decl is Void.

Any ideas on how to tell if a call to a generic function like
withMutableCharacters has a return type of Void in context?

My branch with the work for Part 5 so far is at
https://github.com/tanadeau/swift/commits/sr-1052-use-attr\.

--
Trent Nadeau

--
Trent Nadeau

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/

I replied to the patch: https://github.com/tanadeau/swift/commit/c1b3c8ed688b2bf231a8a0653ebbacd838549d5e#commitcomment-17347334

-Joe

···

On May 3, 2016, at 6:28 PM, Trent Nadeau via swift-dev <swift-dev@swift.org> wrote:

Can anyone help me with this?

Thanks, Joe. I'll give ApplyExpr a try.

···

On Wed, May 4, 2016 at 2:34 PM, Joe Groff <jgroff@apple.com> wrote:

> On May 3, 2016, at 6:28 PM, Trent Nadeau via swift-dev < > swift-dev@swift.org> wrote:
>
> Can anyone help me with this?

I replied to the patch:
https://github.com/tanadeau/swift/commit/c1b3c8ed688b2bf231a8a0653ebbacd838549d5e#commitcomment-17347334

-Joe

--
Trent Nadeau

Thanks for the help. Everything appears to be working, and I created a PR (
https://github.com/apple/swift/pull/2459\) for the changes to use
@discardableResult and have the unused warnings turned on by default.

···

On Wed, May 4, 2016 at 2:36 PM, Trent Nadeau <tanadeau@gmail.com> wrote:

Thanks, Joe. I'll give ApplyExpr a try.

On Wed, May 4, 2016 at 2:34 PM, Joe Groff <jgroff@apple.com> wrote:

> On May 3, 2016, at 6:28 PM, Trent Nadeau via swift-dev < >> swift-dev@swift.org> wrote:
>
> Can anyone help me with this?

I replied to the patch:
https://github.com/tanadeau/swift/commit/c1b3c8ed688b2bf231a8a0653ebbacd838549d5e#commitcomment-17347334

-Joe

--
Trent Nadeau

--
Trent Nadeau