Skip to content

Commit

Permalink
Channel
Browse files Browse the repository at this point in the history
  • Loading branch information
bergel committed Mar 4, 2024
1 parent e0c02e7 commit a73dec8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/linting/extended_checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct Threads_Extension <: ExtendedRule end
struct Generated_Extension <: ExtendedRule end
struct Sync_Extension <: ExtendedRule end
struct RemovePage_Extension <: ExtendedRule end
struct Channel_Extension <: ExtendedRule end

const all_extended_rule_types = Ref{Any}(InteractiveUtils.subtypes(ExtendedRule))

Expand Down Expand Up @@ -196,3 +197,6 @@ function check(::Sync_Extension, x::EXPR)
end

check(::RemovePage_Extension, x::EXPR) = generic_check(x, "remove_page(hole_variable,hole_variable)")

check(::Channel_Extension, x::EXPR) = generic_check(x, "Channel(hole_variable_star)")

12 changes: 11 additions & 1 deletion test/rai_rules_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ end
"Line 18, column 5: `wait` should be used with extreme caution.")
end

@testset "fetch, @inbounds, Atomic, Ptr, remove_page" begin
@testset "fetch, @inbounds, Atomic, Ptr, remove_page, Channel" begin
source = """
function f()
fut = Future{Any}()
Expand Down Expand Up @@ -390,6 +390,12 @@ end
remove_page(pager, pid)
end
end
function foo()
ch1 = Channel()
ch2 = Channel(10)
return (ch1, ch2)
end
"""

@test lint_test(source, "Line 3, column 10: `fetch` should be used with extreme caution.")
Expand All @@ -402,6 +408,10 @@ end
@test lint_test(source, "Line 19, column 22: `Ptr` should be used with extreme caution.")

@test lint_test(source, "Line 24, column 9: `remove_page` should be used with extreme caution.")

@test lint_test(source, "Line 29, column 11: `Channel` should be used with extreme caution.")
@test lint_test(source, "Line 30, column 11: `Channel` should be used with extreme caution.")

end

@testset "Array with no specific type 01" begin
Expand Down

0 comments on commit a73dec8

Please sign in to comment.