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-14932] Emit warning or error on mutually recursive initialization of static variables #57274

Open
typesanitizer opened this issue Jul 16, 2021 · 2 comments
Labels
compiler The Swift compiler in itself improvement

Comments

@typesanitizer
Copy link

Previous ID SR-14932
Radar rdar://problem/80820297
Original Reporter @typesanitizer
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: 36faab10dcbb62f023ce9867cbdc0585

Issue Description:

struct S {
    static var x: Int = y
    static var y: Int = x
}
print(S.x)

With Xcode 13 beta 2, this crashes at runtime without any warnings. IMO it should emit a warning or be an error.

@typesanitizer
Copy link
Author

@swift-ci create

@atrick
Copy link
Member

atrick commented Jul 31, 2021

Task: create a mandatory SIL diagnostic pass, e.g. "DiagnoseInitializerRecursion". This is closely related to DiagnoseInfiniteRecursion. Consider implementing it as part of that pass. This will catch obvious cycles in the initialization call graph, but won't be guaranteed to catch all cases.

@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
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

2 participants