-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
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.standard libraryArea: Standard library umbrellaArea: Standard library umbrella
Description
Previous ID | SR-8156 |
Radar | rdar://problem/41789616 |
Original Reporter | @stephentyrone |
Type | Bug |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 0 |
Component/s | Standard Library |
Labels | Bug |
Assignee | @stephentyrone |
Priority | Medium |
md5: cd2383b8df0c4be4e2e4a03e4f022a94
Issue Description:
One would like to be able to write code like the following:
(swift) func foo<T>( ) -> T where T: FixedWidthInteger {
return T.random(in: 1 ... 6)
}
<REPL Input>:2:10: error: ambiguous reference to member 'random(in:using:)'
return T.random(in: 1 ... 6)
^
Swift.FixedWidthInteger:2:35: note: found this candidate
@inlinable public static func random<T>(in range: Range<Self>, using generator: inout T) -> Self where T : RandomNumberGenerator
^
Swift.FixedWidthInteger:3:35: note: found this candidate
@inlinable public static func random(in range: Range<Self>) -> Self
^
Swift.FixedWidthInteger:2:35: note: found this candidate
@inlinable public static func random<T>(in range: ClosedRange<Self>, using generator: inout T) -> Self where T : RandomNumberGenerator
^
Swift.FixedWidthInteger:3:35: note: found this candidate
@inlinable public static func random(in range: ClosedRange<Self>) -> Self
What's actually necessary here is:
(swift) func foo<T>( ) -> T where T: FixedWidthInteger, T.Stride: SignedInteger, T.Magnitude: UnsignedInteger {
return T.random(in: 1 ... 6)
}
But that's a lot to ask of people.
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.standard libraryArea: Standard library umbrellaArea: Standard library umbrella