Permalink
Browse files

Added some ambiguity warning tess and fixed related bug.

  • Loading branch information...
1 parent 79b995e commit b238ad36b2e2beb65bb2d15cbe631dade7327110 @toivoh committed May 18, 2012
Showing with 8 additions and 1 deletion.
  1. +2 −1 dev/pdispatch.jl
  2. +6 −0 dev/test/test_ambiguity_warning.jl
View
@@ -88,6 +88,8 @@ function add(mt::PatternMethodTable, m::PatternMethod)
end
end
+ ms = mt.methods = PatternMethod[ms[1:i-1]..., m, ms[i:n]...]
+
# warn if new signature is ambiguous with an old one
for m0 in ms
lb, s = unify(m0.pattern, m.pattern)
@@ -101,7 +103,6 @@ function add(mt::PatternMethodTable, m::PatternMethod)
end
end
- mt.methods = PatternMethod[ms[1:i-1]..., m, ms[i:n]...]
nothing
end
@@ -17,6 +17,12 @@ load("pdispatch.jl")
@pattern r3(x,{y,z}) = 2
@pattern r3({x,y},z) = 3
+@pattern r4(1)=1
+@pattern r4(x)=x
+
+@pattern r5(x)=x
+@pattern r5(1)=1
+
# @pattern r4(1,x,y::Int) = 2
# @pattern r4(2,x::Int,y) = 3

0 comments on commit b238ad3

Please sign in to comment.