JuliaObjects/ConstructionBase.jl

Mulltiple test failures when using `--compiled-modules=no` CLI option

Closed this issue · 7 comments

Hi -- I don't know if this is expected behavior, but the package breaks when used with the --compiled-modules=no CLI option. I discovered this while running Turing models -- which depends on ConstructionBase through BangBang -- on an HPC cluster, where disabling the pre-compilation cache is one alternative to solve the problem of multiple process concurrently writing to it. Nevertheless, I have replicated the issue on my laptop by running

julia --compiled-modules=no --project -e "using Pkg; Pkg.test()"

All errors are different iterations of this same issue

MethodError: no method matching is_propertynames_overloaded(::Type{AB{Int64, Int64}})
  The applicable method may be too new: running in world age 31346, while current world is 31404.
  Closest candidates are:
    is_propertynames_overloaded(::Type) at ~/opt/ConstructionBase.jl/src/ConstructionBase.jl:71 (method too new to be called from this world context.)

Computer info

julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

Thanks @miguelbiron for reporting. This is not really expected, I can reproduce the problem on v1.8.0-rc4.
The is_propertynames_overloaded method exists to produce sane errors. As a workaround, you could delete this line https://github.com/JuliaObjects/ConstructionBase.jl/blob/master/src/ConstructionBase.jl#L187
cc @aplavin

I don't know julia inner workings and why exactly this error appears. Maybe, putting this check

function is_propertynames_overloaded(T::Type)::Bool
which(propertynames, Tuple{T}).sig !== Tuple{typeof(propertynames), Any}
end
directly into
if is_propertynames_overloaded(obj)
would help? is_propertynames_overloaded is only used once anyway.

@miguelbiron I think I fixed this issue, can you cobfirm it works in your setup?

Yup, it works now, thank you!

@jw3126 if I may ask: was the issue entirely due to the relative order inside ConstructionBase.jl of is_propertynames_overloaded and the @generated function check_properties_are_fields which calls is_propertynames_overloaded? Can't find other meaningful changes

Yes, it was just the order.

That's crazy. I'll try to remember this whenever I start using generated functions in my packages. Thanks for clarifying!