Skip to content

Inconsistent behaviour of hasproperty with Modules #47150

Open
@tecosaur

Description

@tecosaur
Julia 1.8.2, Linux

I feel like the behavior of {has,get}{property,field} is a bit suspect when it comes to Modules. The following example should be sufficiently illustrative.

julia> hasproperty(Main, :DataFrames)
false

julia> getproperty(Main, :DataFrames)
DataFrames

julia> hasfield(Main, :DataFrames)
ERROR: MethodError: no method matching hasfield(::Module, ::Symbol)
Closest candidates are:
  hasfield(::Type, ::Symbol) at reflection.jl:215
Stacktrace:
 [1] top-level scope
   @ REPL[26]:1

julia> getfield(Main, :DataFrames)
DataFrames

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions