Skip to content

(lib/AST/GenericEnvironment) no generic environment provided for type with type parameters! #61440

@tayloraswift

Description

@tayloraswift

crashes on DEVELOPMENT-SNAPSHOT-2022-09-29-a:

protocol P
{
    subscript<Value>(x:Value) -> Int
    {
        get
    }
}
struct S:P
{
    subscript<Value>(x:Int) -> Value
    {
    }
}
$ swiftc test9.swift 
error: compile command failed due to signal 6 (use -v to see invocation)
test9.swift:12:5: error: missing return in subscript expected to return 'Value'
    }
    ^
test9.swift:8:8: error: type 'S' does not conform to protocol 'P'
struct S:P
       ^
swift-frontend: /home/build-user/swift/lib/AST/GenericEnvironment.cpp:239: static swift::Type swift::GenericEnvironment::mapTypeIntoContext(swift::GenericEnvironment *, swift::Type): Assertion `(env || !type->hasTypeParameter()) && "no generic environment provided for type with type parameters"' failed.
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-29-a/usr/bin/swift-frontend -frontend -c -primary-file test9.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -new-driver-path /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-29-a/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-29-a/usr/lib/swift -module-name test9 -o /tmp/TemporaryDirectory.ZBcDAU/test9-1.o
1.      Swift version 5.8-dev (LLVM 338153f292479fa, Swift b752d7883c26cea)
2.      Compiling with the current language version
3.      While evaluating request TypeCheckSourceFileRequest(source_file "test9.swift")
4.      While type-checking 'S' (at test9.swift:8:1)
5.      While type-checking protocol conformance to 'P' (at test9.swift:1:1) for type 'S' (declared at [test9.swift:8:1 - line:13:1] RangeText="struct S:P
{
    subscript<Value>(x:Int) -> Value
    {
    }
")

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconformancesFeature → protocol: protocol conformancescrashBug: A crash, i.e., an abnormal termination of softwaredeclarationsFeature: declarationsgenericsFeature: generic declarations and typesgood first issueGood for newcomerssubscriptFeature: Subscript declarationstype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions