Skip to content

[SR-3860] error: ambiguous use of operator '-' #46445

Open
@krzyzanowskim

Description

@krzyzanowskim
Previous ID SR-3860
Radar rdar://problem/30393457
Original Reporter @krzyzanowskim
Type Bug

Attachment: Download

Environment

Swift 3.0.2

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.0Regression, TypeChecker
Assignee None
Priority Medium

md5: dc1a3e25eed7f5c5f470127841c056e3

Issue Description:

Given sample does not compile. It does compile for the "+" operation, though.

let arr:[UInt32] = [1,2,3]

_ = UInt32(1 - arr[Int(1)]) // error: ambiguous use of operator '-'
_ = UInt32(1 - arr[1])      // ok
Untitled 12.swift:4:14: error: ambiguous use of operator '-'
_ = UInt32(1 - arr[Int(1)]) // error: ambiguous use of operator '-'
             ^
Swift.-:1:13: note: found this candidate
public func -<T : Strideable>(lhs: T, rhs: T) -> T.Stride
            ^
Swift.-:1:13: note: found this candidate
public func -<T : _DisallowMixedSignArithmetic>(lhs: T, rhs: T) -> T._DisallowMixedSignArithmetic
            ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfregressionswift 3.0type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions