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

@switch fails when matching fields of struct #74

Open
dm3 opened this issue Jan 8, 2018 · 2 comments
Open

@switch fails when matching fields of struct #74

dm3 opened this issue Jan 8, 2018 · 2 comments

Comments

@dm3
Copy link

dm3 commented Jan 8, 2018

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
@NightMachinery
Copy link

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.

@NightMachinery
Copy link

A nice alternative is https://thautwarm.github.io/MLStyle.jl/latest/ .

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

2 participants