tonyhffong / Lint.jl

A lint tool for Julia code
Other
169 stars 33 forks source link

false positive: indexing into iterator #196

Closed mkborregaard closed 7 years ago

mkborregaard commented 7 years ago

This

a = Dict(:b => 2)
keys(a)[1]

gives this spurious error

skaermbillede 2017-02-21 kl 15 16 12

(btw it would be nice to be able to copy the linter errors)

TotalVerb commented 7 years ago

At least in standard Base julia, this error is not spurious:

julia> a = Dict(:b => 2)
Dict{Symbol,Int64} with 1 entry:
  :b => 2

julia> keys(a)[1]
ERROR: MethodError: no method matching getindex(::Base.KeyIterator{Dict{Symbol,Int64}}, ::Int64)

Is there a package that adds this definition?

mkborregaard commented 7 years ago

Holy sh*t that's right. I wasn't thinking.