ERROR: TypeError: non-boolean (Int64) used in boolean context

Dear Julia users,

My codes work in Julia 0.7.0, but when I tried to run them in Julia 1.0.5, I got the following error. It seems this error happens for multiple common Julia functions such as “findall” and etc… Any suggestions?

ERROR: TypeError: non-boolean (Int64) used in boolean context

Stacktrace:
[1] iterate at ./iterators.jl:434 [inlined]
[2] iterate at ./generator.jl:44 [inlined]
[3] grow_to!(::Array{Int64,1}, ::Base.Generator{Base.Iterators.Filter{typeof(last),Base.Iterators.Pairs{Int64,Int64,LinearIndices{1,Tuple{Base.OneTo{Int64}}},Array{Int64,1}}},typeof(first)}) at ./array.jl:674
[4] collect at ./array.jl:617 [inlined]
[5] findall(::Array{Int64,1}) at ./array.jl:2008

If it errors in v1, then you should get a warning in v0.7. Do you not see any?

Without seeing your code, I have to guess a bit, but it looks like you are calling findall on a vector of Int64, and that won’t work. What are you trying to locate in that vector? If it’s non- zero values, then you can try

findall(!iszero, X) 
1 Like

Thanks a lot! I did see three types of warnings in V0.7, as listed below

┌ Warning: Deprecated syntax implicit assignment to global variable ind_run``.

Use global ind_run instead.

@ none:0

┌ Warning: Loop variable ind_run overwrites a variable in an enclosing scope. In the future the variable will be local to the loop instead.

@ none:0

┌ Warning: In the future findall(A) will only work on boolean collections. Use findall(x->x!=0, A) instead.

caller = ip:0x0

@ Core :-1

I think it’s the third warning that’s causing the error. You should implement it’s suggestion and see if that works.

Yes, those will be errors in v1.0.

The last warning and suggestion is the same as the solution I suggested.