Skip to content

Commit 5b9e6d8

Browse files
committed
fix tests
1 parent 4890217 commit 5b9e6d8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/linting/checks.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,9 @@ end
875875

876876
function check_unused_binding(b::Binding, scope::Scope)
877877
if headof(scope.expr) !== :struct && headof(scope.expr) !== :tuple && !all_underscore(valof(b.name))
878-
if (isempty(b.refs) || length(b.refs) == 1 && b.refs[1] == b.name) && !is_sig_arg(b.name) && !is_overwritten_in_loop(b.name) && !is_overwritten_subsequently(b, scope)
879-
seterror!(b.name, UnusedBinding)
878+
refs = loose_refs(b)
879+
if (isempty(refs) || length(refs) == 1 && refs[1] == b.name) && !is_sig_arg(b.name) && !is_overwritten_in_loop(b.name) && !is_overwritten_subsequently(b, scope)
880+
seterror!(b.name, UnusedBinding)
880881
end
881882
end
882883
end

src/utils.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,11 @@ mutable struct LooseRefs
323323
end
324324

325325
function (state::LooseRefs)(x::EXPR)
326-
if hasbinding(x) && valofid(bindingof(x).name) == state.name
327-
push!(state.result, bindingof(x))
326+
if hasbinding(x)
327+
ex = bindingof(x).name
328+
if isidentifier(ex) && valofid(ex) == state.name
329+
push!(state.result, bindingof(x))
330+
end
328331
end
329332
if !hasscope(x) || (hasscope(x) && ((is_soft_scope(scopeof(x)) && !scopehasbinding(scopeof(x), state.name)) || scopeof(x) == state.scope))
330333
traverse(x, state)

0 commit comments

Comments
 (0)