Skip to content

Keypath dynamic member with differently-bound generic self root crashes compiler #77687

Open
@hamishknight

Description

@hamishknight

The following crashes the compiler (in fact it crashes so hard you don't get a backtrace):

@dynamicMemberLookup
struct S<T> {
  subscript<U>(dynamicMember keyPath: KeyPath<S<U>, U>) -> U {
    fatalError()
  }
}
func foo(_ x: S<Int>) {
  x.y
}
Stack dump:
0.      Program arguments: ./swift -frontend -typecheck /Users/hamish/src/swift-test-arena/main.swift -sdk /Users/hamish/src/MacOSX.sdk -debug-diagnostic-names -diagnostic-style=llvm
1.      Swift version 6.1-dev (LLVM 93a0c7d99e811a4, Swift 0234f7ab4a3003b)
2.      Compiling with effective version 5.10
3.      While evaluating request TypeCheckSourceFileRequest(source_file "/Users/hamish/src/swift-test-arena/main.swift")
4.      While evaluating request TypeCheckFunctionBodyRequest(main.(file).foo@/Users/hamish/src/swift-test-arena/main.swift:615:6)
5.      While type-checking statement at [/Users/hamish/src/swift-test-arena/main.swift:615:23 - line:617:1] RangeText="{
  x.y
"
6.      While type-checking expression at [/Users/hamish/src/swift-test-arena/main.swift:616:3 - line:616:5] RangeText="x."
7.      While type-checking-target starting at /Users/hamish/src/swift-test-arena/main.swift:616:5
fish: Job 1, './swift -frontend -typecheck ~/…' terminated by signal SIGSEGV (Address boundary error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    @dynamicMemberLookupFeature → attributes: the @dynamicMemberLookup attributebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwaretype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions