Skip to content

Commit

Permalink
Merge pull request #142 from julia-vscode/pirates
Browse files Browse the repository at this point in the history
piracy fix
  • Loading branch information
ZacLN authored Apr 28, 2020
2 parents 6843434 + 1ddf7f0 commit 6efc9fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/linting/checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ end
function refers_to_nonimported_type(arg::EXPR)
if hasref(arg) && refof(arg) isa Binding
return true
elseif typof(arg) === CSTParser.UnaryOpCall && length(arg) == 2 && kindof(arg[1]) === CSTParser.Tokens.DECLARATION
elseif typof(arg) === CSTParser.UnaryOpCall && length(arg) == 2 && (kindof(arg[1]) === CSTParser.Tokens.DECLARATION || kindof(arg[1]) === CSTParser.Tokens.ISSUBTYPE)
return refers_to_nonimported_type(arg[2])
elseif _binary_assert(arg, CSTParser.Tokens.DECLARATION)
return refers_to_nonimported_type(arg[3])
Expand Down
17 changes: 17 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,23 @@ end
StaticLint.check_for_pirates(cst[2])
@test errorof(cst[2]) === nothing
end
let cst = parse_and_pass("""
import Base:sin
abstract type T end
sin(x::Array{T}) = 1
sin(x::Array{<:T}) = 1
sin(x::Array{Number}) = 1
sin(x::Array{<:Number}) = 1
""")
StaticLint.check_for_pirates(cst[3])
StaticLint.check_for_pirates(cst[4])
StaticLint.check_for_pirates(cst[5])
StaticLint.check_for_pirates(cst[6])
@test errorof(cst[3]) === nothing
@test errorof(cst[4]) === nothing
@test errorof(cst[5]) === StaticLint.TypePiracy
@test errorof(cst[6]) === StaticLint.TypePiracy
end
end

@testset "docs for undescribed variables" begin
Expand Down

0 comments on commit 6efc9fa

Please sign in to comment.