[SR-15111] “Type of expression is ambiguous” error when initializing a class
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 32/100
Research direction
Run the provided Swift example in the stated Xcode environment and compare the diagnostics for the direct optional-member argument and the intermediate variable. Investigate the compiler type-checker behavior described by the Compiler and TypeChecker labels; done means the direct call reports the same type-mismatch diagnostic as the second call.
Written by the indexing model from the issue text.
Description
| Previous ID | SR-15111 |
| Radar | rdar://problem/82407752 |
| Original Reporter | elidy (JIRA User) |
| Type | Bug |
Environment
Xcode Version 13.0 beta 4 (13A5201i)
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, DiagnosticsQoI, StarterBug, TypeChecker |
| Assignee | elidy (JIRA) |
| Priority | Medium |
md5: 37c1160eb7b2424ea42b3ec849906fef
Issue Description:
When a class is initialized, passing an argument as a property of an optional class instance of incorrect type results in “Type of expression is ambiguous” error.
class IntClass {
var int: Int?
init(int: Int?) {
self.int = int
}
}
class StringClass {
var string: String? = "hello"
}
var stringClass: StringClass? = StringClass()
IntClass(int: stringClass?.string)
//Type of expression is ambiguous without more context
//Expected error: Cannot convert value of type 'String?' to expected argument type 'Int?'
var stringValue = stringClass?.string
IntClass(int: stringValue)
//Cannot convert value of type 'String?' to expected argument type 'Int?'
- Dominant language
- Swift
- Stars
- 70.4k
- Forks
- 10.8k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 461
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from swiftlang/swift
-
triage needed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
triage needed
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Foundation Windows
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
triage needed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
triage needed
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Similar issues
-
type: docs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
googleapis/google-cloud-swift#971 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mozilla-mobile/firefox-ios#35743 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
manaflow-ai/cmux#13417 ·
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
ionic-team/capacitor#8616 ·