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

@fgenerator doesn't play nicely with argument destructuring #20

Open
simeonschaub opened this issue Nov 6, 2021 · 0 comments
Open

@fgenerator doesn't play nicely with argument destructuring #20

simeonschaub opened this issue Nov 6, 2021 · 0 comments

Comments

@simeonschaub
Copy link

The following currently throws an error:

julia> struct B x end

julia> @fgenerator((; x)::B) do
           @yield x
       end
ERROR: LoadError: MethodError: no method matching length(::Expr)
Closest candidates are:
  length(::Union{Base.KeySet, Base.ValueIterator}) at ~/packages/julias/julia-1.7/share/julia/base/abstractdict.jl:58
  length(::Union{LinearAlgebra.Adjoint{T, S}, LinearAlgebra.Transpose{T, S}} where {T, S}) at ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/LinearAlgebra/src/adjtrans.jl:171
  length(::VSCodeServer.JSON.Parser.PushVector) at ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/JSON/src/pushvector.jl:13
  ...
Stacktrace:
  [1] length(g::Base.Generator{Expr, FGenerators.var"#10#13"})
    @ Base ./generator.jl:50
  [2] _similar_shape(itr::Base.Generator{Expr, FGenerators.var"#10#13"}, #unused#::Base.HasLength)
    @ Base ./array.jl:600
  [3] collect(itr::Base.Generator{Expr, FGenerators.var"#10#13"})
    @ Base ./array.jl:723
  [4] define_foldl(__module__::Module, funcname::Expr, structname::Symbol, allargs::Expr, body::Expr)
    @ FGenerators ~/.julia/packages/FGenerators/N3bhz/src/FGenerators.jl:285
  [5] var"@fgenerator"(__source__::LineNumberNode, __module__::Module, fun::Any, coll::Any)
    @ FGenerators ~/.julia/packages/FGenerators/N3bhz/src/FGenerators.jl:245
  [6] eval
    @ ./boot.jl:373 [inlined]
  [7] eval
    @ ./Base.jl:68 [inlined]
  [8] repleval(m::Module, code::Expr, #unused#::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/repl.jl:157
  [9] (::VSCodeServer.var"#71#73"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/repl.jl:123
 [10] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:511
 [11] with_logger
    @ ./logging.jl:623 [inlined]
 [12] (::VSCodeServer.var"#70#72"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/repl.jl:124
 [13] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [14] invokelatest(::Any)
    @ Base ./essentials.jl:714
 [15] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [16] (::VSCodeServer.var"#55#56")()
    @ VSCodeServer ./task.jl:411
in expression starting at REPL[6]:1

So it seems like the @fgenerator assumes the argument is always a symbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant