-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software
Description
| Previous ID | SR-6062 |
| Radar | rdar://problem/34835322 |
| Original Reporter | @natecook1000 |
| Type | Bug |
Environment
swift/master @ aed8c33
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, CompilerCrash |
| Assignee | None |
| Priority | Medium |
md5: 21a6322780a9e431f9d545abfc86f173
Issue Description:
The following code tries to use a key-path expressions to access the key/default subscript on a dictionary, but results in a compiler crash:
var d = [1: 1, 2: 2]
print(d[keyPath: \[Int: Int].[1, default: 0]])
----
TYPE MISMATCH IN ARGUMENT 1 OF APPLY AT expression at [/Users/nate/Desktop/kp1.swift:2:18 - line:2:44] RangeText="\[Int: Int].[1, default: 0]" argument value: %8 = load [trivial] %7 : $*Int parameter type: $@callee_owned () -> @out IntI'm not sure if that's the right syntax—omitting the default: label results in an an "expression is ambiguous" error:
var d = [1: 1, 2: 2]
print(d[keyPath: \[Int: Int].[1, 0]])
----
/Users/nate/Desktop/kp1.swift:2:18: error: type of expression is ambiguous without more context
print(d[keyPath: \[Int: Int].[1, 0]])
^~~~~~~~~~~~~~~~~~Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software