Navigation Menu

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-13639] Code after return, inconsistent diagnostics and behavior #56075

Open
jepers opened this issue Oct 1, 2020 · 1 comment
Open

[SR-13639] Code after return, inconsistent diagnostics and behavior #56075

jepers opened this issue Oct 1, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@jepers
Copy link

jepers commented Oct 1, 2020

Previous ID SR-13639
Radar rdar://problem/69845495
Original Reporter @jepers
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee guitardog (JIRA)
Priority Medium

md5: 93178b7c4343d2f9fee8e7bba810aecd

Issue Description:

The following program runs and prints a series of numbers, so either the warning is misleading or the behavior is not as intended.

func foo() -> Int {

  return _E.bar

  struct _E { // WARNING: Code after 'return' will never be executed
    private static var count = 0
    static var bar: Int {
      count += (Bool.random() ? foo() : 1)
      return count
    }
  }
}

for _ in 0 ..< 7 { print(foo()) }

Related thread (with more similar examples):
https://forums.swift.org/t/should-this-misleading-warning-be-here/40678

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 in itself
Projects
None yet
Development

No branches or pull requests

2 participants