Skip to content

Commit

Permalink
Fix julia-vscode#382. Remove spurious method call error in function d…
Browse files Browse the repository at this point in the history
…efinition.
  • Loading branch information
zengmao committed Dec 12, 2024
1 parent d514414 commit 8a1bd84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/linting/checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,13 @@ function sig_match_any(func::EXPR, x, call_counts, tls::Scope, env::ExternalEnv)
else
return true # We shouldn't get here
end
if compare_f_call(m_counts, call_counts) || (CSTParser.rem_where_decl(CSTParser.get_sig(func)) == x)
if compare_f_call(m_counts, call_counts)
return true
else
x1 = CSTParser.rem_where_decl(CSTParser.get_sig(func))
if (x1.head == :call && x1 == x) || (!(x1.args isa Nothing) && x1.args[1].head == :call && x1.args[1] == x)
return true
end
end
return false
end
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,14 @@ f(arg) = arg
@test errorof(cst.args[3].args[2].args[1].args[3].args[1].args[1]) !== StaticLint.InvalidRedefofConst
end

@testset "issue #382" begin
cst = parse_and_pass("""
function f(a::T, invert=false)::T where {T <: Integer}
invert ? -a : a
end""")
@test !StaticLint.haserror(cst.args[1].args[1].args[1].args[1])
end

if VERSION > v"1.5-"
@testset "issue #210" begin
cst = parse_and_pass("""h()::@NamedTuple{a::Int,b::String} = (a=1, b = "s")""")
Expand Down

0 comments on commit 8a1bd84

Please sign in to comment.