Files
swift-mirror/test/Constraints/diag_ambiguities.swift
Doug Gregor 9ba865e852 Diagnose ambiguity type-checks by pointing to candidates.
Introduces very basic support for diagnosing ambiguous expressions,
where the source of the ambiguity is a reference to an overloaded
name. Simple example:

t.swift:4:1: error: ambiguous use of 'f0'
f0(1, 2)
^
t.swift:1:6: note: found this candidate
func f0(i : Int, d : Double) {}
     ^
t.swift:2:6: note: found this candidate
func f0(d : Double, i : Int) {}
     ^

There's a lot of work needed to make this cleaner, but perhaps it will
ease the pain of developing the library <rdar://problem/14277889>.


Swift SVN r6195
2013-07-12 00:45:17 +00:00

20 lines
647 B
Swift

// RUN: %swift -parse %s -verify
func f0(i : Int, d : Double) {} // expected-note{{found this candidate}}
func f0(d : Double, i : Int) {} // expected-note{{found this candidate}}
f0(1, 2) // expected-error{{ambiguous use of 'f0'}}
func f1(i : Int16) {} // expected-note{{found this candidate}}
func f1(i : Int32) {} // expected-note{{found this candidate}}
f1(0) // expected-error{{ambiguous use of 'f1'}}
operator infix +++ { }
func +++(i : Int, d : Double) {} // expected-note{{found this candidate}}
func +++(d : Double, i : Int) {} // expected-note{{found this candidate}}
1 +++ 2 // expected-error{{ambiguous use of operator '+++'}}