Skip to content

[SR-6300] Compiler crash with mismatched key paths #48850

@stephencelis

Description

@stephencelis
Previous ID SR-6300
Radar rdar://problem/35368903
Original Reporter @stephencelis
Type Bug
Status Resolved
Resolution Done
Environment

November 4 Swift Trunk Snapshot

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

md5: 3886fb02f71ca8ac991f7cf076ec23f2

is duplicated by:

  • SR-6311 Array subscript takes any KeyPath and leads to undefined behavior and crashes

relates to:

  • SR-6311 Array subscript takes any KeyPath and leads to undefined behavior and crashes

Issue Description:

The following code crashes the compiler.

struct Foo { let foo: Int }
struct Bar { let bar: String }

Bar(bar: "Hello!")[keyPath: \Foo.foo]

The crash:

TYPE MISMATCH IN ARGUMENT 0 OF APPLY AT expression at
RangeText="Bar(bar: "Hello!")[keyPath: \Foo.foo]"

Ideally this is a normal compiler error, instead.

Metadata

Metadata

Assignees

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 softwarekey pathsFeature: key paths (both native and Objective-C)type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions