Skip to content

ValSplit broken on Julia 1.10? #2

@svilupp

Description

@svilupp

This is a really nifty utility, however, I keep getting errors on Julia 1.10.
It breaks Transformers.jl on Julia 1.10 as well (see link)

Is there a way to fix it? I've tried to narrow it down, but it's over my head!

Running the example in README:

using ValSplit

soundof(animal::Val{:dog}) = "woof"
soundof(animal::Val{:cat}) = "nyan"

@valsplit function soundof(Val(animal::Symbol))
    error("Sound not defined for animal: \$animal")
end

soundof(:dog) # Error!

Stacktrace:

ERROR: MethodError: no method matching iterate(::Nothing)

Closest candidates are:
  iterate(::Base.MethodSpecializations)
   @ Base reflection.jl:1146
  iterate(::Base.MethodSpecializations, ::Nothing)
   @ Base reflection.jl:1152
  iterate(::Base.MethodSpecializations, ::Int64)
   @ Base reflection.jl:1153
  ...

Stacktrace:
  [1] iterate(::Base.Iterators.Filter{Tricks.var"#7#9"{Nothing}, Nothing})
    @ Base.Iterators ./iterators.jl:516
  [2] iterate(::Base.Generator{Base.Iterators.Filter{Tricks.var"#7#9"{Nothing}, Nothing}, Tricks.var"#6#8"})
    @ Base ./generator.jl:44
  [3] _collect(::Type{Method}, itr::Base.Generator{Base.Iterators.Filter{Tricks.var"#7#9"{Nothing}, Nothing}, Tricks.var"#6#8"}, isz::Base.SizeUnknown)
    @ Base ./array.jl:698
  [4] collect(::Type{Method}, itr::Base.Generator{Base.Iterators.Filter{Tricks.var"#7#9"{Nothing}, Nothing}, Tricks.var"#6#8"})
    @ Base ./array.jl:692
  [5] _methods(f_type::Any, t_type::Any, mod::Nothing)
    @ Tricks ~/.julia/packages/Tricks/7oAyo/src/Tricks.jl:146
  [6] _methods(f_type::Any, t_type::Any, mod::Nothing)
    @ Tricks ~/.julia/packages/Tricks/7oAyo/src/Tricks.jl:143 [inlined]
  [7] #s3#3
    @ ValSplit ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:42 [inlined]
  [8] var"#s3#3"(T::Any, N::Any, P::Any, ::Any, f::Any, types::Any, idx::Any, ptype::Any)
    @ ValSplit ./none:0
  [9] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:600
 [10] valarg_params(f::typeof(soundof), types::Type{Tuple{Val}}, idx::Val{1}, ptype::Type{Symbol})
    @ ValSplit ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:60 [inlined]
 [11] soundof(animal::Symbol)
    @ Main ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:141
 [12] top-level scope
    @ ~/Documents/xyz/transformers/valsplit.jl:12

@code_typed soundof(:dog) returns (different from the README)

CodeInfo(
1 ─ %1 = Main.soundof::typeof(soundof)
│   %2 = Main.Symbol::Type{Symbol}
│   %3 = invoke ValSplit.valarg_params(%1::typeof(soundof), Tuple{Val}::Type{Tuple{Val}}, $(QuoteNode(Val{1}()))::Val{1}, %2::Type{Symbol})::Any
│   %4 = %new(Main.:(var"#3#default_f#5"))::var"#3#default_f#5"
│   %5 = Core.apply_type(Base.Val, %3)::Type{Val{_A}} where _A
│   %6 = %new(%5)::Val
│   %7 = ValSplit._valswitch(%6, $(QuoteNode(Val{1}())), Main.soundof, %4, animal)::Any
└──      return %7
) => Any

Versioninfo:

Julia Version 1.10.0-beta1
Commit 6616549950e (2023-07-25 17:43 UTC)
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 8 × Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 on 6 virtual cores
Environment:
JULIA_EDITOR = code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions