Skip to content

Commit 41d3156

Browse files
authored
Merge pull request #360 from BenPH/fix-resolve-getfield-for-nonstdindentifier
Fix resolve_getfield for non standard identifiers
2 parents b3b804a + f89539d commit 41d3156

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/references.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ function resolve_getfield(x::EXPR, parent_type::EXPR, state::State)::Bool
203203
if CSTParser.defines_module(parent_type) && scopeof(parent_type) isa Scope
204204
resolved = resolve_ref(x, scopeof(parent_type), state)
205205
elseif CSTParser.defines_struct(parent_type)
206-
if scopehasbinding(scopeof(parent_type), valof(x))
207-
setref!(x, scopeof(parent_type).names[valof(x)])
206+
if scopehasbinding(scopeof(parent_type), valofid(x))
207+
setref!(x, scopeof(parent_type).names[valofid(x)])
208208
resolved = true
209209
end
210210
end

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,12 +646,17 @@ f(arg) = arg
646646
name
647647
func
648648
func1
649+
struct AnyType
650+
var"anything"
651+
end
652+
anything(x::AnyType) = x.var"anything"
649653
""")
650654
StaticLint.collect_hints(cst, getenv(server.files[""], server))
651655
@test all(n in keys(cst.meta.scope.names) for n in ("name", "func"))
652656
@test StaticLint.hasref(cst[4])
653657
@test StaticLint.hasref(cst[5])
654658
@test StaticLint.hasref(cst[6])
659+
@test cst.args[8].args[2].args[1].args[2].args[1] in bindingof(cst.args[7].args[3].args[1]).refs
655660
end
656661
end
657662
end

0 commit comments

Comments
 (0)