Skip to content
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

[SR-15151] @discardableResult not propagated through return value / continuation #57477

Open
stephencelis opened this issue Sep 3, 2021 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression type checker Area → compiler: Semantic analysis

Comments

@stephencelis
Copy link
Contributor

Previous ID SR-15151
Radar rdar://problem/82877277
Original Reporter @stephencelis
Type Bug
Environment

Swift 5.5

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: e80ffb61f8bb865977bd306915574028

Issue Description:

Not sure if it's practical to fix, but the following example produces an unused return value warning.

class MyViewModel: ObservableObject {
  @Published var array = ["A", "B", "C"]

  func removeFirst() {
    // warning: Result of call to 'withAnimation' is unused
    withAnimation {
      self.array.removeFirst()
    }
  }
}

Worse, when result builders are involved we get an error:

struct MyView: View {
  @State var array = ["A", "B", "C"]

  // error: Failed to produce diagnostic for expression
  var body: some View {
    Button("Remove first") {
      withAnimation {
        self.array.removeFirst()
      }
    }
  }
}
@typesanitizer
Copy link

It looks like JIRA botched the code example, could you please fix it? I tried fixing it locally but I hit a confusing error for which I've filed https://bugs.swift.org/browse/SR-15153

@stephencelis
Copy link
Contributor Author

theindigamer (JIRA User) Updated! The view builder one actually errors, but I introduced a second code block showing the warning.

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@dfeinzimer
Copy link

Is this related to #60276? We're still seeing the warning in the Xcode 14.0 (14A309) release.

@stephencelis
Copy link
Contributor Author

@dfeinzimer No this is a different issue / feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants