REPL error

bug

#1

I get the following reproducible error with showing an object in REPL. The object itself is fine and no error shows up when I suppress the output with ;

julia> c = VTKDataTypes.VTKMultiblockData([a,b]);

julia> c
VTKDataTypes.VTKMultiblockData(Error showing value of type VTKDataTypes.VTKMulti
blockData:
ERROR: UndefVarError: T not defined
 in Pair{A,B}(::Symbol, ::VTKDataTypes.VTKMultiblockData) at .\operators.jl:590
 in show_default(::IOContext{Base.Terminals.TTYTerminal}, ::Any) at .\show.jl:12
4
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text
/plain")}, ::VTKDataTypes.VTKMultiblockData) at .\REPL.jl:132
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::VTKDataTypes.VTKM
ultiblockData) at .\REPL.jl:135
 in display(::VTKDataTypes.VTKMultiblockData) at .\multimedia.jl:143
 in print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool,
::Void) at .\REPL.jl:154
 in print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at .
\REPL.jl:139
 in (::Base.REPL.##22#23{Bool,Base.REPL.##33#42{Base.REPL.LineEditREPL,Base.REPL
.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineE
dit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at .\REPL.jl:652
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface)
at .\LineEdit.jl:1579
 in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at .\REPL
.jl:903
 in run_repl(::Base.REPL.LineEditREPL, ::Base.##932#933) at .\REPL.jl:188
 in _start() at .\client.jl:360


#2

You need to provide versioninfo() and the definition of the type, at least.


#3

Its v0.5.0.

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
  System: NT (x86_64-w64-mingw32)
  CPU: AMD A10-8700P Radeon R6, 10 Compute Cores 4C+6G
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Excavator)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, bdver4)

Here is the type definition.

type VTKMultiblockData <: AbstractVTKMultiblockData
    blocks::Vector{AbstractStaticVTKData}
end

And here is the whole file of types.

abstract AbstractVTKData

abstract AbstractStaticVTKData <: AbstractVTKData
abstract AbstractTimeSeriesVTKData <: AbstractVTKData

abstract AbstractVTKSimpleData <: AbstractStaticVTKData
abstract AbstractVTKAMRData <: AbstractStaticVTKData
abstract AbstractVTKMultiblockData <: AbstractStaticVTKData

abstract AbstractVTKUnstructuredData <: AbstractVTKSimpleData
abstract AbstractVTKStructuredData <: AbstractVTKSimpleData
abstract AbstractVTKRectilinearData <: AbstractVTKStructuredData

type VTKUnstructuredData{T} <: AbstractVTKUnstructuredData
    point_coords::Matrix{T}
    cell_types::Vector{Int}
    cell_connectivity::Vector{Vector{Int}}
    point_data::Dict{String, Array{T}}
    cell_data::Dict{String, Array{T}}

    function VTKUnstructuredData(point_coords, cell_types, cell_connectivity, point_data, cell_data)
        dataset = new(point_coords, cell_types, cell_connectivity, point_data, cell_data)
        valid, _error = is_valid(dataset)
        valid ? (return dataset) : throw(_error)
    end
end
VTKUnstructuredData{T}(point_coords::Matrix{T}, cell_types::Vector{Int},
    cell_connectivity::Vector{Vector{Int}}, point_data::Dict{String, Array{T}},
    cell_data::Dict{String, Array{T}}) = VTKUnstructuredData{T}(point_coords, cell_types,
    cell_connectivity, point_data, cell_data)

type VTKPolyData{T} <: AbstractVTKUnstructuredData
    point_coords::Matrix{T}
    cell_types::Vector{Int}
    cell_connectivity::Vector{Vector{Int}}
    point_data::Dict{String, Array{T}}
    cell_data::Dict{String, Array{T}}

    function VTKPolyData(point_coords, cell_types, cell_connectivity, point_data, cell_data)
        dataset = new(point_coords, cell_types, cell_connectivity, point_data, cell_data)
        valid, _error = is_valid(dataset)
        valid ? (return dataset) : throw(_error)
    end
end
VTKPolyData{T}(point_coords::Matrix{T}, cell_types::Vector{Int},
    cell_connectivity::Vector{Vector{Int}}, point_data::Dict{String, Array{T}},
    cell_data::Dict{String, Array{T}}) = VTKPolyData{T}(point_coords, cell_types,
    cell_connectivity, point_data, cell_data)

type VTKStructuredData{T} <: AbstractVTKStructuredData
    point_coords::Array{T}
    point_data::Dict{String, Array{T}}
    cell_data::Dict{String, Array{T}}

    function VTKStructuredData(point_coords, point_data, cell_data)
        dataset = new(point_coords, point_data, cell_data)
        valid, _error = is_valid(dataset)
        valid ? (return dataset) : throw(_error)
    end
end
VTKStructuredData{T}(point_coords::Array{T}, point_data::Dict{String, Array{T}}, 
    cell_data::Dict{String, Array{T}}) = VTKStructuredData{T}(point_coords, point_data, cell_data)

type VTKRectilinearData{T} <: AbstractVTKRectilinearData
    point_coords::Vector{Vector{T}}
    point_data::Dict{String, Array{T}}
    cell_data::Dict{String, Array{T}}

    function VTKRectilinearData(point_coords, point_data, cell_data)
        dataset = new(point_coords, point_data, cell_data)
        valid, _error = is_valid(dataset)
        valid ? (return dataset) : throw(_error)
    end
end
VTKRectilinearData{T}(point_coords::Vector{Vector{T}}, point_data::Dict{String, Array{T}}, 
    cell_data::Dict{String, Array{T}}) = VTKRectilinearData{T}(point_coords, point_data, cell_data)

type VTKUniformRectilinearData{T} <: AbstractVTKRectilinearData
    origin::Vector{T}
    spacing::Vector{T}
    extents::Vector{Int}
    point_data::Dict{String, Array{T}}
    cell_data::Dict{String, Array{T}}

    function VTKUniformRectilinearData(origin, spacing, extents, point_data, cell_data)
        dataset = new(origin, spacing, extents, point_data, cell_data)
        valid, _error = is_valid(dataset)
        valid ? (return dataset) : throw(_error)
    end
end
VTKUniformRectilinearData{T}(origin::Vector{T}, spacing::Vector{T}, extents::Vector{Int},
    point_data::Dict{String, Array{T}}, cell_data::Dict{String, Array{T}}) = 
    VTKUniformRectilinearData{T}(origin, spacing, extents, point_data, cell_data)

#=
type VTKBergerOligerAMRData <: AbstractVTKAMRData
    data::VTKUniformRectilinearData
    children::Vector{VTKBergerOligerAMRData}
    children_boundary_cells::Matrix{Int}
end
=#

type VTKMultiblockData <: AbstractVTKMultiblockData
    blocks::Vector{AbstractStaticVTKData}
end

type VTKTimeSeriesData{T, S<:AbstractStaticVTKData} <: AbstractTimeSeriesVTKData
    timemarkers::Vector{T}
    data::Array{S}

    function VTKTimeSeriesData(timemarkers, data)
        dataset = new(timemarkers, data)
        valid, _error = is_valid(dataset)
        valid ? (return dataset) : throw(_error)
    end
end


#4

Have you tried with the current release of v0.5? (v0.5.2)?


#5

No, it’s not really bothering me, but I thought of reporting it anyways.


#6

What are the definitions of a and b, that you use in c = VTKDataTypes.VTKMultiblockData([a,b]);?
I’m trying to reproduce your error on v0.5.2 (and then v0.6.0-rc2 and master)


#7

As a general rule, please provide as much information so that actually reproducing the error message is possible. The easier it is, the more likely someone will actually look into it. A block of code that can be copy-pasted is the best.


#8

My bad, a was VTKRectilinearData and b was VTKUnstructuredData. You can remove the validation part, and use the following types instead.

abstract AbstractVTKData

abstract AbstractStaticVTKData <: AbstractVTKData
abstract AbstractVTKSimpleData <: AbstractStaticVTKData
abstract AbstractVTKMultiblockData <: AbstractStaticVTKData

abstract AbstractVTKUnstructuredData <: AbstractVTKSimpleData
abstract AbstractVTKStructuredData <: AbstractVTKSimpleData
abstract AbstractVTKRectilinearData <: AbstractVTKStructuredData

type VTKUnstructuredData{T} <: AbstractVTKUnstructuredData
    point_coords::Matrix{T}
    cell_types::Vector{Int}
    cell_connectivity::Vector{Vector{Int}}
    point_data::Dict{String, Array{T}}
    cell_data::Dict{String, Array{T}}
end
VTKUnstructuredData{T}(point_coords::Matrix{T}, cell_types::Vector{Int},
    cell_connectivity::Vector{Vector{Int}}, point_data::Dict{String, Array{T}},
    cell_data::Dict{String, Array{T}}) = VTKUnstructuredData{T}(point_coords, cell_types,
    cell_connectivity, point_data, cell_data)

type VTKRectilinearData{T} <: AbstractVTKRectilinearData
    point_coords::Vector{Vector{T}}
    point_data::Dict{String, Array{T}}
    cell_data::Dict{String, Array{T}}
end
VTKRectilinearData{T}(point_coords::Vector{Vector{T}}, point_data::Dict{String, Array{T}}, 
    cell_data::Dict{String, Array{T}}) = VTKRectilinearData{T}(point_coords, point_data, cell_data)

type VTKMultiblockData <: AbstractVTKMultiblockData
    blocks::Vector{AbstractStaticVTKData}
end


#9

Ok, I was trying to avoid a self-contained example because it may use a lot of code. But here is one you can copy and paste. Firstly, you will need a significant amount of the partially untested code in the following link.

https://www.expirebox.com/download/afe9f7fb65c9852fb5400a5721709abf.html

Then the following is the error generating example.

x = y = z = [0., 1., 2., 3., 4.];
point_coords = [x,y,z];
point_data = Dict{String, Array{Float64}}();
cell_data = Dict{String, Array{Float64}}();
a = VTKRectilinearData(point_coords, point_data, cell_data);
x = y = z = [5., 6., 7., 8., 9.];
point_coords = [x,y,z];
b = VTKUnstructuredData(VTKRectilinearData(point_coords, point_data, cell_data));
c = VTKMultiblockData([a, b])

#10

FYI, I reproduced the error in v0.5.2.


#11

Julia 0.6.0-rc3.0 also gives an error. In fact it gives another error too that 0.5 did not give.

julia> x = y = z = [0., 1., 2., 3., 4.];

julia> point_coords = [x,y,z];

julia> point_data = Dict{String, Array{Float64}}();

julia> cell_data = Dict{String, Array{Float64}}();

julia> a = VTKDataTypes.VTKRectilinearData(point_coords, point_data, cell_data);


julia> a.cell_data["Color"] = reshape(rand(VTKDataTypes.num_of_cells(a)), (([VTKDataTypes.extents(a)...] .- 1)...))
Error showing value of type Array{Float64,3}:
ERROR: write: i/o error (EIO)
Stacktrace:
 [1] try_yieldto(::Base.##296#297{Task}, ::Task) at .\event.jl:189
 [2] wait() at .\event.jl:234
 [3] uv_write(::Base.TTY, ::Ptr{UInt8}, ::UInt64) at .\stream.jl:811
 [4] unsafe_write(::Base.TTY, ::Ptr{UInt8}, ::UInt64) at .\stream.jl:832
 [5] print at .\strings\io.jl:122 [inlined]
 [6] #showarray#263(::Bool, ::Function, ::IOContext{Base.Terminals.TTYTerminal},
 ::Array{Float64,3}, ::Bool) at .\show.jl:1690
 [7] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("tex
t/plain")}, ::Array{Float64,3}) at .\REPL.jl:122
 [8] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Array{Float64,3}
) at .\REPL.jl:125
 [9] display(::Array{Float64,3}) at .\multimedia.jl:194
 [10] eval(::Module, ::Any) at .\boot.jl:235
 [11] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool
, ::Void) at .\REPL.jl:144
 [12] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at
 .\REPL.jl:129
 [13] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,
Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::B
ase.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at .\REPL
.jl:646

julia> x = y = z = [5., 6., 7., 8., 9.];

julia> point_coords = [x,y,z];

julia> b = VTKDataTypes.VTKUnstructuredData(VTKDataTypes.VTKRectilinearData(point_coords, point_data, cell_data));

julia> b.cell_data["Color"] = rand(VTKDataTypes.num_of_cells(b));

julia> c = VTKDataTypes.VTKMultiblockData([a, b]);

julia> c
VTKDataTypes.VTKMultiblockData(Error showing value of type VTKDataTypes.VTKMultiblockData:
ERROR: UndefVarError: T not defined
Stacktrace:
 [1] Pair(::Symbol, ::VTKDataTypes.VTKMultiblockData) at .\pair.jl:4
 [2] show_default(::IOContext{Base.Terminals.TTYTerminal}, ::Any) at .\show.jl:1
34
 [3] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("tex
t/plain")}, ::VTKDataTypes.VTKMultiblockData) at .\REPL.jl:122
 [4] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::VTKDataTypes.VTK
MultiblockData) at .\REPL.jl:125
 [5] display(::VTKDataTypes.VTKMultiblockData) at .\multimedia.jl:194
 [6] eval(::Module, ::Any) at .\boot.jl:235
 [7] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool,
 ::Void) at .\REPL.jl:144
 [8] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at
.\REPL.jl:129
 [9] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,B
ase.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Ba
se.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at .\REPL.
jl:646

Another more weird and serious error happens when calling

julia> d = [c]
ERROR: UndefVarError: T not defined
Stacktrace:
 [1] vect(::VTKDataTypes.VTKMultiblockData, ::Vararg{VTKDataTypes.VTKMultiblockD
ata,N} where N) at .\array.jl:76

julia> d
ERROR: UndefVarError: d not defined

#12

The error is in:

convert(::Type{VTKMultiblockData}, dataset::AbstractStaticVTKData) = VTKMultiblockData(T[dataset])

where indeed T is undefined. Now, the error message is quite unhelpful because it doesn’t point to the correct place. I found the problem by running with --inline=no. I believe the inlining problem (causing unhelpful backtrace) is covered by the issue https://github.com/JuliaLang/julia/issues/20474


#13

Great, thank you so much :slight_smile:


#14

FWIW, Lint.jl (last release version) reports

W543 T: Lint cannot determine if Type or not
W544 T: Lint cannot determine if Type or not

and Lint.jl master reports

E321 T: use of undeclared symbol