Lazy.jl
Lazy.jl copied to clipboard
@switch fails when matching fields of struct
Julia 0.6.2, Lazy 0.12
julia> struct Ints x :: Int end
julia> z = Ints(1)
Ints(1)
julia> Lazy.@switch z.x begin 1; println("one") end
ERROR: TypeError: non-boolean (Int64) used in boolean context
@switch
on variables works as expected:
julia> x = 1
1
julia> Lazy.@switch x begin 1; println("one") end
one
This problem doesn't seem fixed in the latest versions. Is there a workaround? Trying someStruct.someField == _
also gives the error ERROR: LoadError: syntax: all-underscore identifier used as rvalue around /Users/evar/.julia/packages/Lazy/KYseE/src/macros.jl:45
.
A nice alternative is https://thautwarm.github.io/MLStyle.jl/latest/ .