Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG] Using optional optional types from Configurations fails with an error. #228

Closed
VPetukhov opened this issue Dec 1, 2022 · 0 comments · Fixed by #229
Closed

[BUG] Using optional optional types from Configurations fails with an error. #228

VPetukhov opened this issue Dec 1, 2022 · 0 comments · Fixed by #229
Labels
bug Something isn't working

Comments

@VPetukhov
Copy link
Contributor

Describe the bug
Using optional optional types from Configurations fails with an error.

Version of the package:
1.0.0, julia 1.8.3

To Reproduce

module M

using Comonicon
using Configurations

@option struct Opts
    x::String = "x"
end

"""
# Options
- `-c, --config <path/to/option/or/specific field>`: config.
"""
@main function main(;config::Opts=Opts())
    @show config
end

end

M.command_main()

ERROR: KeyError: key :config not found
Stacktrace:
[1] getindex(h::Dict{Symbol, Any}, key::Symbol)
@ Base ./dict.jl:498
[2] command_main(ARGS::Vector{String})
@ Main.M ~/.julia/dev/Comonicon/src/codegen/julia.jl:277
[3] command_main()
@ Main.M ~/.julia/dev/Comonicon/src/codegen/julia.jl:90
[4] top-level scope
@ REPL[2]:1

Expected behavior
The function should show config = Main.M.Opts("x")

Reason
Accessing kwargs in emit_leaf_call assumes that the option was already stored, which happens only for required options (afaik).

@VPetukhov VPetukhov added the bug Something isn't working label Dec 1, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant