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-15847] Circular required convenience init pattern not caught by compiler #58121

Open
swift-ci opened this issue Feb 10, 2022 · 3 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation regression SIL swift 5.1

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-15847
Radar rdar://problem/89076581
Original Reporter Kaspra (JIRA User)
Type Bug
Environment

All OS, platforms and hardware on Swift 5.5.2

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, 5.1Regression, SILDiagnostics
Assignee None
Priority Medium

md5: 9f39cfcea60e60ce15f9f5b749a489f0

Issue Description:

class Foo {

required convenience init(x: Int) {

self.init(x: x)

}

}

This circular init pattern is not caught by the compiler, but dropping the required or convenience individually gives a warning or error as expected.

@itaiferber
Copy link
Contributor

I don't know how related these issues are, but some additional info:

  • I do see the expected warning when compiling with swift from the command line:

    $ swift Test.swift
    Test.swift:3:14: warning: function call causes an infinite recursion
            self.init(x: x)
                 ^
    $

    This happens with or without optimization enabled

  • I don't see a warning when compiling with swiftc directly, regardless of optimizations:

    $ swiftc Test.swift
    $
  • I don't see a warning for the above code in Xcode when building a Debug build, but do when building a Release build

Also for reference, Swift forums thread: https://forums.swift.org/t/circular-init-pattern-not-caught-by-compiler/55249

@theblixguy
Copy link
Collaborator

This is a regression from Swift 5.1 onwards, on Swift 5.0 we correctly diagnose the infinite recursion. cc @eeckstein

@eeckstein
Copy link
Member

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added diagnostics QoI Bug: Diagnostics Quality of Implementation SIL and removed SILDiagnostics labels Nov 2, 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 diagnostics QoI Bug: Diagnostics Quality of Implementation regression SIL swift 5.1
Projects
None yet
Development

No branches or pull requests

5 participants