1)In fresh repl or in a repl without multiplying irrationals previously, 
this gist 
<https://gist.github.com/tomaklutfu/6c9ca295c8fd86bec5d21a8d73837484> 
somehow adds a method for  *(Irrational,Irrational)
and gives error on the next use of multiplications of the same irrational 
like pi*pi but not pi*eulergamma.

   _       _ _(_)_     |  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> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> methods(*,(Irrational{:π},Irrational{:π}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> module Erratic


           const BaseIrrationals = Union{Irrational{:e},Irrational{:catalan
},Irrational{:γ},
                                         Irrational{:π},Irrational{:φ}}
           abstract DummyReal <: Real
           immutable SymReal <: DummyReal
               var::BaseIrrationals
           end


           mulSym(x::BaseIrrationals, y::BaseIrrationals) = x*y
           mulSym(x::SymReal, y::SymReal)  = SymReal(mulSym(x.var, y.var))
           mulSym(x::BaseIrrationals, y::SymReal)  = SymReal(mulSym(x, y.var
))
           mulSym(x::SymReal, y::BaseIrrationals)= SymReal(mulSym(x.var, y))


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


       end
Erratic


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> methods(*,(Irrational{:π},Irrational{:π}))
# 1 method for generic function "*":
*{T<:Number}(x::T, y::T) at promotion.jl:256


julia> pi*pi
ERROR: * not defined for Irrational{:π}
 in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256


julia> pi*e
8.539734222673566


2)However, if multiplications of irrationals is used previously it doesn't 
give error except @code_** shows erroneous new method.

   _       _ _(_)_     |  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> pi*pi
9.869604401089358


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> module Erratic


           const BaseIrrationals = Union{Irrational{:e},Irrational{:catalan
},Irrational{:γ},
                                         Irrational{:π},Irrational{:φ}}
           abstract DummyReal <: Real
           immutable SymReal <: DummyReal
               var::BaseIrrationals
           end


           mulSym(x::BaseIrrationals, y::BaseIrrationals) = x*y
           mulSym(x::SymReal, y::SymReal)  = SymReal(mulSym(x.var, y.var))
           mulSym(x::BaseIrrationals, y::SymReal)  = SymReal(mulSym(x, y.var
))
           mulSym(x::SymReal, y::BaseIrrationals)= SymReal(mulSym(x.var, y))


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


       end
Erratic


julia> pi*pi
9.869604401089358


julia> methods(*,(Irrational{:π},Irrational{:π}))
# 1 method for generic function "*":
*{T<:Number}(x::T, y::T) at promotion.jl:256


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> pi*e
8.539734222673566


julia> @code_lowered pi*pi
LambdaInfo template for *{T<:Number}(x::T, y::T) at promotion.jl:256
:(begin 
        nothing
        return (Base.no_op_err)("*",$(Expr(:static_parameter, 1)))
    end)


It happens both on 0.4(.5) and 0.5-rc3.
Is this a bug or otherwise what happens here?

Reply via email to