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-8003] Compiler crashed on protocol associatedtype constraint #50536

Closed
swift-ci opened this issue Jun 15, 2018 · 6 comments
Closed

[SR-8003] Compiler crashed on protocol associatedtype constraint #50536

swift-ci opened this issue Jun 15, 2018 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8003
Radar rdar://problem/41161320
Original Reporter cxa (JIRA User)
Type Bug
Status Closed
Resolution Duplicate

Attachment: Download

Environment

Xcode 10 Beta 1 on Mojave Beta 1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: 2754d47d438c61bdc86e8a2ec8dea92f

duplicates:

  • SR-7331 Diagnose protocol 'where' clause with constraints on 'Self'

Issue Description:

Suppose I have simple code that contains protocol associated type like:

protocol Controller {
  associatedtype Model
  associatedtype Event

  func updateModel(_ model: Model, forEvent event: Event) -> Void
}

protocol View where Self: NSObjectProtocol {
  associatedtype Model
  associatedtype Event

  typealias EventEmitter = (Event) -> Void
  func bindModel(_ model: Model) -> Void
  func bindEvent(by emitter: @escaping EventEmitter, model: Model) -> Void
}

struct MiniMVC<Model, Event> {
  static func glue<V: View, C: Controller>(model: Model, view: V, controller: C)
    where V.Model == Model, V.Event == Event,
          C.Model == Model, C.Event == Event
  {

  }
}

When using `MiniMVC` like:

MiniMVC.glue(model: model, view: view, controller: controller)

Compiler will crash: Segmentation fault: 11.

@AnthonyLatsis
Copy link
Collaborator

cc @slavapestov

@AnthonyLatsis
Copy link
Collaborator

Crashes on the Self constraint to an @objc protocol. Minimal case:

import Foundation

@objc protocol OBJC {}
protocol Protocol where Self: OBJC {}

struct Test {
  static func foo<V: Protocol>(arg: V) {}
}

Assertion failed:

Assertion failed: (argType == parent->getParent()->mapTypeIntoContext( SGF.getSILType(parameterInfo)) && "argument does not have same type as specified by parameter info"), function visitType, file /Volumes/Elements/swift-source/swift/lib/SILGen/SILGenProlog.cpp, line 104.

1. While emitting SIL for 'foo(arg:)' at /Users/polzovatel/Desktop/test.swift:7:3
2. While silgen emitFunction SIL function "@$S4test4TestV3foo3argyx_tAA8ProtocolRzlFZ".

@belkadan
Copy link
Contributor

Thanks for the reduction, Anthony! cc @huonw

@swift-ci create

@slavapestov
Copy link
Member

This is another "Self constraint doesn't work" bug. I'll get around to fixing this soon I swear 🙂

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Jul 23, 2019

cxa (JIRA User), The project does not crash anymore. Could you confirm that the problem is fixed and if so move the bug to Closed state?

@AnthonyLatsis
Copy link
Collaborator

I can confirm this is fixed as well in Xcode 11 beta and a recent master

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
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 crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

4 participants