Open johnnychen94 opened 2 years ago
Positional constructor is supported but it should only be your default constructor. You should write MyOption(1, 2) not just MyOption(1)
I can see why you think there is a constructor with vararg. But I don't think having that is very useful in more complicated case given there's already a keyword constructor and this is the same behavior of Base.@kedef
For a normal struct type without such constructor I think you get a similar error isn't it?
My apologies for not describing it very clearly. I was hoping the error stack become cleaner/shorter, e.g.,:
julia> Base.@kwdef struct MyOption
x::Int
y::Int = 1
end
MyOption
julia> MyOption(1)
ERROR: MethodError: no method matching MyOption(::Int64)
Closest candidates are:
MyOption(::Int64, ::Int64) at REPL[1]:2
MyOption(::Any, ::Any) at REPL[1]:2
MyOption(; x, y) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/util.jl:478
Stacktrace:
[1] top-level scope
@ REPL[2]:1
could not determine location of method definition
Oh I guess this is a julia issue with not so good support for codegen methods?
just need to insert the line number correctly in this package: https://github.com/Roger-luo/Expronicon.jl
MyOption(2)
throws some encrypted error messages besides the core errorMethodError: no method matching MyOption(::Int64)
Maybe it's a good idea to eagerly generate dummy and descriptive messages here, e.g., defining
Is it https://github.com/Roger-luo/Configurations.jl/blob/6aad922a0074d1bc9a6cb2235b2c5f76437cd1fb/src/codegen.jl?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L351-L353 that handles this codegen?