Skip to content

Commit

Permalink
Added @generated
Browse files Browse the repository at this point in the history
  • Loading branch information
bergel committed Mar 4, 2024
1 parent 4291e80 commit c241f9d
Show file tree
Hide file tree
Showing 2 changed files with 12 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 @@ -64,6 +64,7 @@ struct Atomic_Extension <: ExtendedRule end
struct Ptr_Extension <: ExtendedRule end
struct ArrayWithNoType_Extension <: ExtendedRule end
struct Threads_Extension <: ExtendedRule end
struct Generated_Extension <: ExtendedRule end

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

Expand Down Expand Up @@ -183,3 +184,6 @@ function check(::Threads_Extension, x::EXPR)
generic_check(x, "Threads.@threads hole_variable", msg)
generic_check(x, "@threads hole_variable", msg)
end

check(::Generated_Extension, x::EXPR) = generic_check(x, "@generated hole_variable")

9 changes: 8 additions & 1 deletion test/rai_rules_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end
"Line 2, column 5: Macro `@cfunction` should not be used.")
end

@testset "@lock ,@threads" begin
@testset "@lock, @threads, @generated" begin
source = """
function mark_transaction_as_database_creation!(kv::SpcsKV, transaction_id::String)
@lock kv.latch begin
Expand All @@ -78,12 +78,19 @@ end
end
return nothing
end
@generated function _empty_vector(::Type{T}) where {T}
vec = T[]
return vec
end
"""
@test lint_has_error_test(source)
@test lint_test(source,
"Line 2, column 5: `@lock` should be used with extreme caution")
@test lint_test(source,
"Line 7, column 5: `@threads` should be used with extreme caution.")
@test lint_test(source,
"Line 14, column 1: `@generated` should be used with extreme caution.")
end


Expand Down

0 comments on commit c241f9d

Please sign in to comment.