Skip to content

compiler crash: Functions in generic context must have an interface type #61387

@tayloraswift

Description

@tayloraswift

reproduced on DEVELOPMENT-SNAPSHOT-2022-09-27-a:

struct S 
{
    static 
    func x(_ s:some StringProtocol) -> String 
    {
        .init(s)
    }
    static
    subscript(s:some StringProtocol) -> String 
    {
        Self.x(s)
    }
}
$ swiftc test8.swift 
error: compile command failed due to signal 6 (use -v to see invocation)
Functions in generic context must have an interface type
(accessor_decl range=[test8.swift:10:5 - line:12:5] 'anonname=0xbef4aa0' interface type=' (S.Type) -> (some StringProtocol) -> String' access=internal captures=(<generic> ) type get_for=subscript(_:)
  (parameter "self")
  (parameter_list range=[test8.swift:9:14 - line:9:36]
    (parameter "s" type='some StringProtocol' interface type='some StringProtocol'))
  (call_expr type='String' location=test8.swift:11:14 range=[test8.swift:11:9 - line:11:17] nothrow
    (dot_syntax_call_expr type='(some StringProtocol) -> String' location=test8.swift:11:14 range=[test8.swift:11:9 - line:11:14] nothrow
      (declref_expr type='(S.Type) -> (some StringProtocol) -> String' location=test8.swift:11:14 range=[test8.swift:11:14 - line:11:14] decl=test8.(file).S.x@test8.swift:4:10 [with (substitution_map generic_signature= (substitution some StringProtocol -> some StringProtocol))] function_ref=single)
      (argument_list implicit
        (argument
          (type_expr type='S.Type' location=test8.swift:11:9 range=[test8.swift:11:9 - line:11:9] typerepr='S'))))
    (argument_list
      (argument
        (declref_expr type='some StringProtocol' location=test8.swift:11:16 range=[test8.swift:11:16 - line:11:16] decl=test8.(file).S.<anonymous>.s@test8.swift:9:15 function_ref=unapplied)))))
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.      Program arguments: /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-27-a/usr/bin/swift-frontend -frontend -c -primary-file test8.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -new-driver-path /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-27-a/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-27-a/usr/lib/swift -module-name test8 -o /tmp/TemporaryDirectory.nrsWjH/test8-1.o
1.      Swift version 5.8-dev (LLVM ed4d811c2897d77, Swift 8491f52d478aca6)
2.      Compiling with the current language version
3.      While walking into decl 'S' (at test8.swift:1:1)
4.      While walking into 'S' (at test8.swift:1:1)
5.      While verifying AccessorDecl getter for subscript(_:) (at test8.swift:9:5)
6.      While verifying FuncDecl getter for subscript(_:) (at test8.swift:9:5)
7.      While verifying AbstractFunctionDecl getter for subscript(_:) (at test8.swift:9:5)

does not crash if the subscript is desugared to the where-based syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA 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