Closed
Description
I tested this on Julia 1.8.5 and 1.9beta3 (on an M1 mac but we've seen this on other architectures as well)
struct DiscriminatedUnion{S, T<:S}
type::String
value::T
end
abstract type Car end
struct Audi <: Car end
struct Mercedes <: Car end
function concrete_type_mapping(::Type{Car})
(
audi = Audi,
mercedes = Mercedes,
)
end
function subtypes(t::Type{<:DiscriminatedUnion{S}}) where {S}
SUP = fieldtypes(t)[2]
map(T -> DiscriminatedUnion{SUP,T}, concrete_type_mapping(SUP))
end
subtypes(DiscriminatedUnion{Car})
Calling subtypes
prints out this super long trace, at the end of which you can see the correct output (audi = DiscriminatedUnion{Car, Audi}, mercedes = DiscriminatedUnion{Car, Mercedes})
.
I can avoid the error by replacing map(T -> DiscriminatedUnion{SUP,T}, concrete_type_mapping(SUP))
with
NamedTuple([
key => DiscriminatedUnion{SUP,T} for (key, T) in pairs(concrete_type_mapping(SUP))
])
Internal error: encountered unexpected error in runtime:
TypeError(func=:<:, context="", expected=Type, got=S)
ijl_type_error_rt at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_type_error at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_f_issubtype at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
apply_type_nothrow at ./compiler/tfuncs.jl:1360
_builtin_nothrow at ./compiler/tfuncs.jl:1737
builtin_nothrow at ./compiler/tfuncs.jl:1862 [inlined]
builtin_effects at ./compiler/tfuncs.jl:1848
abstract_call_known at ./compiler/abstractinterpretation.jl:1627
abstract_call at ./compiler/abstractinterpretation.jl:1786
abstract_call at ./compiler/abstractinterpretation.jl:1753
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1910
typeinf_local at ./compiler/abstractinterpretation.jl:2386
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2482
_typeinf at ./compiler/typeinfer.jl:230
typeinf at ./compiler/typeinfer.jl:213
typeinf_ext at ./compiler/typeinfer.jl:967
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1000
typeinf_ext_toplevel at ./compiler/typeinfer.jl:996
jfptr_typeinf_ext_toplevel_15369 at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/sys.dylib (unknown line)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_type_infer at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_generate_fptr_impl at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-codegen.1.8.dylib (unknown line)
jl_compile_method_internal at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
map at ./tuple.jl:222 [inlined]
map at ./namedtuple.jl:219
subtypes at ./Untitled-1:20
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_call at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
eval_body at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_interpret_toplevel_thunk at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
top-level scope at Untitled-1:23
jl_toplevel_eval_flex at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_toplevel_eval_flex at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_toplevel_eval_in at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
eval at ./boot.jl:368 [inlined]
include_string at ./loading.jl:1428
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_f__call_latest at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:729
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
invokelatest at ./essentials.jl:726
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#inlineeval#71 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:233
inlineeval##kw at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:230 [inlined]
#66 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:157
withpath at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/repl.jl:249
#65 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:155
hideprompt at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/repl.jl:38
#64 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:126
unknown function (ip: 0x1ccf6482f)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
with_logstate at ./logging.jl:511
with_logger at ./logging.jl:623 [inlined]
#63 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:225
unknown function (ip: 0x1ccf645ff)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_f__call_latest at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:729 [inlined]
invokelatest at ./essentials.jl:726
unknown function (ip: 0x11fe67982)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
macro expansion at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
#61 at ./task.jl:484
unknown function (ip: 0x11fe441ff)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
start_task at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
Internal error: encountered unexpected error in runtime:
TypeError(func=:<:, context="", expected=Type, got=S)
ijl_type_error_rt at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_type_error at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_f_issubtype at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
apply_type_nothrow at ./compiler/tfuncs.jl:1360
_builtin_nothrow at ./compiler/tfuncs.jl:1737
builtin_nothrow at ./compiler/tfuncs.jl:1862 [inlined]
builtin_effects at ./compiler/tfuncs.jl:1848
abstract_call_known at ./compiler/abstractinterpretation.jl:1627
abstract_call at ./compiler/abstractinterpretation.jl:1786
abstract_call at ./compiler/abstractinterpretation.jl:1753
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1910
typeinf_local at ./compiler/abstractinterpretation.jl:2386
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2482
_typeinf at ./compiler/typeinfer.jl:230
typeinf at ./compiler/typeinfer.jl:213
typeinf_ext at ./compiler/typeinfer.jl:967
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1000
typeinf_ext_toplevel at ./compiler/typeinfer.jl:996
jfptr_typeinf_ext_toplevel_15369 at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/sys.dylib (unknown line)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_type_infer at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_generate_fptr_impl at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-codegen.1.8.dylib (unknown line)
jl_compile_method_internal at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
map at ./tuple.jl:222 [inlined]
map at ./namedtuple.jl:219
subtypes at ./Untitled-1:20
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_call at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
eval_body at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_interpret_toplevel_thunk at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
top-level scope at Untitled-1:23
jl_toplevel_eval_flex at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_toplevel_eval_flex at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_toplevel_eval_in at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
eval at ./boot.jl:368 [inlined]
include_string at ./loading.jl:1428
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_f__call_latest at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:729
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
invokelatest at ./essentials.jl:726
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#inlineeval#71 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:233
inlineeval##kw at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:230 [inlined]
#66 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:157
withpath at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/repl.jl:249
#65 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:155
hideprompt at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/repl.jl:38
#64 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:126
unknown function (ip: 0x1ccf6482f)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
with_logstate at ./logging.jl:511
with_logger at ./logging.jl:623 [inlined]
#63 at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:225
unknown function (ip: 0x1ccf645ff)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_f__call_latest at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:729 [inlined]
invokelatest at ./essentials.jl:726
unknown function (ip: 0x11fe67982)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_apply at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
macro expansion at /Users/krumbiegel/.vscode/extensions/julialang.language-julia-1.45.1/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
#61 at ./task.jl:484
unknown function (ip: 0x11fe441ff)
ijl_apply_generic at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
start_task at /Users/krumbiegel/.julia/juliaup/julia-1.8.5+0.x64.apple.darwin14/lib/julia/libjulia-internal.1.8.dylib (unknown line)
(audi = DiscriminatedUnion{Car, Audi}, mercedes = DiscriminatedUnion{Car, Mercedes})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment