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-13810] Runtime crash when using incremental compilation mode instead of whole module #56207

Open
swift-ci opened this issue Nov 3, 2020 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 3, 2020

Previous ID SR-13810
Radar rdar://problem/70999142
Original Reporter Baoshan (JIRA User)
Type Bug
Environment

Swift 5.3

Xcode 12.1

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: c812e8d8eaa9ba73bfd322ba28771e58

Issue Description:

    • Struct.swift --

      struct Struct {
          private var _property = Wrapper<Property?>()
          var isArray: Bool { _property.isArray }
      }
    • main.swift --

      protocol Protocol {
          associatedtype ElementValue: Singular
          static var isArray: Bool { get }
      }
      
      protocol Singular: Equatable, NonOptional {
          associatedtype ElementValue = Self
      }
      
      extension Singular {
          static var isArray: Bool { false }
          public static func == (lhs: Self, rhs: Self) -> Bool {
              fatalError()
          }
      }
      
      protocol NonOptional: Protocol {
          associatedtype ElementValue = Self
      }
      
      extension Optional: Protocol where Wrapped: NonOptional {
          typealias ElementValue = Wrapped.ElementValue
          static var isArray: Bool { Wrapped.isArray }
      }
      
      struct Wrapper <T: Protocol> {
          var wrappedValue: T { fatalError() }
          var isArray: Bool { T.isArray }
      }
      
      struct Property {
          var value: Int
      }
      
      extension Property: Singular { }
      
      assert(Struct().isArray == false)

      Above source compiles fine but crashes at runtime. The title may be misleading. Actually if we perform any of the below actions, the program executes as expected:

  1. Combine the source code into one single file (move `Struct` definition either to the top or bottom of `main.swift`).

  2. Remove `Equatable`

  3. Remove `ElementValue` typealias & associatedtype

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 3, 2020

Comment by Baoshan Sheng (JIRA)

When the compilation mode is set to `whole module` instead of `incremental`, the program executes as expected, may this be the real culprit?

@typesanitizer
Copy link

cc @CodaFi

@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.
Projects
None yet
Development

No branches or pull requests

2 participants