A reduced case that also makes multiplication of the same Irrational an 
error.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |  x86_64-linux-gnu


julia> module Erratic


           const DummyUnion =  Union{Irrational,AbstractFloat}
           abstract DummyReal <: Real
           immutable DummyType <: DummyReal
               var::DummyUnion
           end


           mulSym(x::DummyUnion, y::DummyUnion) = x*y
           mulSym(x::DummyUnion, y::DummyType)  = DummyType(mulSym(x, y.var
))


           import Base.*
           *(x::DummyUnion, y::DummyReal) = mulSym(x, y)


       end
Erratic


julia> pi*pi
ERROR: * not defined for Irrational{:π}
 in error(::String, ::String, ::Vararg{Any,N}) at ./error.jl:22
 in no_op_err(::String, ::Type{T}) at ./promotion.jl:254
 in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256
 in eval(::Module, ::Any) at ./boot.jl:234


julia> pi*Erratic.DummyType(pi)
ERROR: * not defined for Irrational{:π}
 in error(::String, ::String, ::Vararg{Any,N}) at ./error.jl:22
 in no_op_err(::String, ::Type{T}) at ./promotion.jl:254
 in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256
 in mulSym(::Irrational{:π}, ::Irrational{:π}) at ./REPL[1]:9
 in mulSym(::Irrational{:π}, ::Erratic.DummyType) at ./REPL[1]:10
 in *(::Irrational{:π}, ::Erratic.DummyType) at ./REPL[1]:13
 in eval(::Module, ::Any) at ./boot.jl:234


julia> pi*Erratic.DummyType(2.)
Erratic.DummyType(6.283185307179586)

DummyReal does not cover Irrationals but it somehow triggers default 
*{T<:Number}(x::T, y::T) = no_op_err("*", T)
What kind of number does not have multiplication defined with itself?

Reply via email to