Skip to content

[Diagnostics] Suppress unused expression warning if result is discard… #65445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2023

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Apr 26, 2023

…able pack expansion

Examine pack expansion pattern to determine whether expression
result could be discarded without a warning (applies to tuples with
a single unlabeled pack expansion element as well).

Resolves: rdar://108064941

…able pack expansion

Examine pack expansion pattern to determine whether expression
result could be discarded without a warning (applies to tuples
with a single unlabeled pack expansion element as well).

Resolves: rdar://108064941
@xedin
Copy link
Contributor Author

xedin commented Apr 26, 2023

@swift-ci please test

Copy link
Member

@hborla hborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

}

func test2<each T>(_ value: repeat each T) {
((repeat arr.append(each value))) // no warning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to do this with a tuple instead of just writing the underlying pack expansion expression? I'm wondering if we should still diagnose this for tuples

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it that way because users don't actually know that this is a tuple, syntactically it's just parens which seems reasonable to make consistent with non-variadic cases.

@xedin
Copy link
Contributor Author

xedin commented May 1, 2023

@swift-ci please smoke test macOS platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants