Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurations errors when using e as the variable name. 🤷 #101

Open
schlichtanders opened this issue Mar 28, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@schlichtanders
Copy link

schlichtanders commented Mar 28, 2024

I just build a tiny test example for Configurations which unforunately breaks.
EDIT: simplified the example further

using Configurations: @option, from_dict

@option struct OptionFails
    d::Union{Nothing, String} = nothing
    e::String
end

from_dict(OptionFails, Dict("d" => nothing, "e" => "hi"))

throws

ERROR: MethodError: no method matching haskey(::Nothing, ::String)

Closest candidates are:
  haskey(::LibGit2.CachedCredentials, ::Any)
   @ LibGit2 ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LibGit2/src/types.jl:1309
  haskey(::LibGit2.GitTree, ::AbstractString)
   @ LibGit2 ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LibGit2/src/tree.jl:192
  haskey(::RegexMatch, ::Union{AbstractString, Symbol})
   @ Base regex.jl:279
  ...

Stacktrace:
 [1] macro expansion
   @ ./essentials.jl:0 [inlined]
 [2] from_dict_specialize(::Type{MyC8}, d::Dict{String, Union{Nothing, String}})
   @ Main ~/.julia/packages/Configurations/Yxczn/src/codegen.jl:362
 [3] from_dict(::Type{MyC8}, d::Dict{String, Union{Nothing, String}}; kw::@Kwargs{})
   @ Configurations ~/.julia/packages/Configurations/Yxczn/src/from_dict.jl:46
 [4] from_dict(::Type{MyC8}, d::Dict{String, Union{Nothing, String}})
   @ Configurations ~/.julia/packages/Configurations/Yxczn/src/from_dict.jl:33
 [5] top-level scope
   @ REPL[30]:1

Suprisingly just changing the variable names makes it work

@option struct OptionWorks
    a::Union{Nothing, String} = nothing
    b::String
end
from_dict(OptionWorks, Dict("a" => nothing, "b" => "hi"))
@schlichtanders schlichtanders changed the title MethodError: no method matching haskey(::Nothing, ::String) Configurations errors when using e as the variable name. 🤷 Mar 28, 2024
@Roger-luo Roger-luo added the bug Something isn't working label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants