Julia MethodError(f=typeof(Core.Compiler.fieldindex())

Julia MethodError(f=typeof(Core.Compiler.fieldindex()),julia,Julia,我有下面一段代码,其中我尝试通过treestocastic类型扩展类型系统 module my_mod abstract type ScalarVariate <: Real end abstract type ArrayVariate{N} <: DenseArray{Float64, N} end abstract type TreeVariate <: Any end const AbstractVariate = Union{ScalarVariate, Arr

我有下面一段代码,其中我尝试通过
treestocastic
类型扩展类型系统

module my_mod



abstract type ScalarVariate <: Real end
abstract type ArrayVariate{N} <: DenseArray{Float64, N} end
abstract type TreeVariate <: Any end

const AbstractVariate = Union{ScalarVariate, ArrayVariate, TreeVariate}

#################### My Types ####################

mutable struct Node
    name::String
    data::Array{Float64,2}
end

mutable struct ScalarLogical <: ScalarVariate
  value::Float64
  symbol::Symbol
end

mutable struct ArrayLogical{N} <: ArrayVariate{N}
  value::Array{Float64, N}
  symbol::Symbol
end

mutable struct ScalarStochastic <: ScalarVariate
  value::Float64
  symbol::Symbol
end

mutable struct ArrayStochastic{N} <: ArrayVariate{N}
  value::Array{Float64, N}
  symbol::Symbol
end

mutable struct TreeStochastic <: TreeVariate
    value::Node
    symbol::Symbol
end

const AbstractLogical = Union{ScalarLogical, ArrayLogical}
const AbstractStochastic = Union{ScalarStochastic, ArrayStochastic, TreeStochastic}
const AbstractDependent = Union{AbstractLogical, AbstractStochastic}


Base.size(v::AbstractVariate) = size(v.value)

function Stochastic(d::Integer)
  if d == 0
    value = Float64(NaN)
    s = ScalarStochastic(value, :nothing)
  else
    value = Array{Float64}(undef, fill(0,d)...)
    s = ArrayStochastic(value, :nothing)
  end
  s
end

function Logical(d::Integer)
  if d == 0
    value = Float64(NaN)
    s = ScalarLogical(value, :nothing)
  else
    value = Array{Float64}(undef, fill(0,d)...)
    s = ArrayLogical(value, :nothing)
  end
  s
end

function Stochastic(d::AbstractString)
  TreeStochastic(Node("",zeros(Float64,(1,2))), :nothing)
end

function Model(; nodes...)
  nodedict = Dict{Symbol, Any}()
  for (key, value) in nodes
    isa(value, AbstractDependent) || throw(ArgumentError("nodes are not all Dependent types"))
    node = deepcopy(value)
    node.symbol = key
    nodedict[key] = node
  end
  nodedict
end

end
如果我在没有
z=my_mod.randomic(“t”)
的情况下运行该函数,则一切正常


任何帮助都将不胜感激。

根据Julia团队的说法,错误应该通过Pull request#31670修复,这是Julia 1.2的一部分。因此,使用Julia 1.2或更高版本应该可以修复问题。

乍一看,这看起来像是一个错误-请在这里报告:奇怪的是,错误在第二次调用时消失,所以它就消失了似乎与编译时间有关。我还注意到另一件奇怪的事情:当通过Juno调试器执行函数时,错误不会显示。我将在官方github上报告它。感谢您的帮助!
include("f1.jl")
using .my_mod
my_mod.Model(y=my_mod.Stochastic(1),x=my_mod.Logical(2), z=my_mod.Stochastic("t"))