diff --git a/src/static/bindings.jl b/src/static/bindings.jl index c3c90174..466e87ea 100644 --- a/src/static/bindings.jl +++ b/src/static/bindings.jl @@ -172,9 +172,12 @@ function mark_binding!(x::EXPR, val = x) mark_binding!(x.args[1], x) elseif typof(x) === CSTParser.InvisBrackets mark_binding!(CSTParser.rem_invis(x), val) - elseif typof(x) == CSTParser.UnaryOpCall && + elseif typof(x) === CSTParser.UnaryOpCall && kindof(x.args[1]) === CSTParser.Tokens.DECLARATION return x + elseif typof(x) === CSTParser.Ref + # https://github.com/JunoLab/Juno.jl/issues/502 + return x else# if typof(x) === IDENTIFIER || (typof(x) === BinaryOpCall && kindof(x.args[2]) === CSTParser.Tokens.DECLARATION) x.meta = Binding(CSTParser.get_name(x), val) end diff --git a/test/static/bindings.jl b/test/static/bindings.jl index 919193c1..ff32a7fb 100644 --- a/test/static/bindings.jl +++ b/test/static/bindings.jl @@ -5,6 +5,7 @@ Adapted from https://github.com/julia-vscode/CSTParser.jl/blob/e4e32477a1e7b4d57 =# using Atom: traverse_expr!, bindingof +using CSTParser using CSTParser: typof function collect_bindings(ex) @@ -90,3 +91,6 @@ let cst = CSTParser.parse("function a::T * b::T end") end @test collect_bindings(CSTParser.parse("-(x::T) = x")) == ["-", "x"] + +# https://github.com/JunoLab/Juno.jl/issues/502 +@test isempty(collect_bindings(CSTParser.parse("ary[ind] = rand(Int)"))) diff --git a/test/static/toplevel.jl b/test/static/toplevel.jl index 5df21ab2..7ccc6324 100644 --- a/test/static/toplevel.jl +++ b/test/static/toplevel.jl @@ -29,3 +29,6 @@ for t in ["f(call())", "f(call(), @macro)", "f(@macro)", "f(@macro, arg; kwarg = @test length(items) === 1 @test items[1] isa Atom.ToplevelCall end + +# https://github.com/JunoLab/Juno.jl/issues/502 +@test isempty(toplevelitems("ary[ind] = some"))