Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FrontIR to allowed users of Shape #78

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/linting/extended_checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
!is_there_any_star_marker && return x == y

contains(x, "QQQ") && contains(y, "QQQ") &&
throw(BothCannotHaveStarException("Cannot both $x and $y have a star marker"))

Check failure on line 58 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use $(x) instead of $x ([explanation](https://github.com/RelationalAI/RAIStyle?tab=readme-ov-file#string-interpolation)). raicode/src/linting/extended_checks.jl
if contains(x, "QQQ")
reg_exp = Regex(replace(x, "QQQ" => ".*"))
return !isnothing(match(reg_exp, y))
Expand Down Expand Up @@ -268,7 +268,7 @@

function get_recommendation(msg_prefix)
m = retrieve_full_msg_from_prefix(msg_prefix)
m in keys(is_recommendation) || return nothing

Check failure on line 271 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `tin(item,collection)` instead of the Julia's `in` or `∈`. raicode/src/linting/extended_checks.jl
return is_recommendation[m]
end

Expand Down Expand Up @@ -311,7 +311,7 @@
end

function check_for_recommendation(T::DataType, msg::String)
@assert supertype(T) in [RecommendationExtendedRule, ViolationExtendedRule]

Check failure on line 314 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `tin(item,collection)` instead of the Julia's `in` or `∈`. raicode/src/linting/extended_checks.jl
b = supertype(T) == RecommendationExtendedRule
get!(is_recommendation, msg, b)
return nothing
Expand Down Expand Up @@ -343,7 +343,7 @@

function check(t::NThreads_Extention, x::EXPR, markers::Dict{Symbol,String})
# Threads.nthreads() must not be used in a const field, but it is allowed elsewhere
haskey(markers, :const) || return

Check failure on line 346 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `thaskey(dict,key)` instead of the Julia's `haskey`. raicode/src/linting/extended_checks.jl
generic_check(t, x, "Threads.nthreads()", "`Threads.nthreads()` should not be used in a constant variable.")
end

Expand Down Expand Up @@ -397,11 +397,11 @@
check(t::Ptr_Extension, x::EXPR) = generic_check(t, x, "Ptr{hole_variable}(hole_variable)")

function check(t::ArrayWithNoType_Extension, x::EXPR, markers::Dict{Symbol,String})
haskey(markers, :filename) || return

Check failure on line 400 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `thaskey(dict,key)` instead of the Julia's `haskey`. raicode/src/linting/extended_checks.jl
contains(markers[:filename], "src/Compiler") || return

haskey(markers, :macrocall) && markers[:macrocall] == "@match" && return

Check failure on line 403 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `thaskey(dict,key)` instead of the Julia's `haskey`. raicode/src/linting/extended_checks.jl
haskey(markers, :macrocall) && markers[:macrocall] == "@matchrule" && return

Check failure on line 404 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `thaskey(dict,key)` instead of the Julia's `haskey`. raicode/src/linting/extended_checks.jl

generic_check(t, x, "[]", "Need a specific Array type to be provided.")
end
Expand Down Expand Up @@ -441,7 +441,7 @@
end

function check(t::Unsafe_Extension, x::EXPR, markers::Dict{Symbol,String})
haskey(markers, :function) || return

Check failure on line 444 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `thaskey(dict,key)` instead of the Julia's `haskey`. raicode/src/linting/extended_checks.jl
isnothing(match(r"_unsafe_.*", markers[:function])) || return
isnothing(match(r"unsafe_.*", markers[:function])) || return

Expand Down Expand Up @@ -538,7 +538,7 @@
end

function check(t::RelPathAPIUsage_Extension, x::EXPR, markers::Dict{Symbol,String})
haskey(markers, :filename) || return

Check failure on line 541 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `thaskey(dict,key)` instead of the Julia's `haskey`. raicode/src/linting/extended_checks.jl
contains(markers[:filename], "src/Compiler/Front") || return

generic_check(t, x, "hole_variable::RelPath", "Usage of type `RelPath` is not allowed in this context.")
Expand All @@ -550,11 +550,12 @@
end

function check(t::NonFrontShapeAPIUsage_Extension, x::EXPR, markers::Dict{Symbol,String})
haskey(markers, :filename) || return

Check failure on line 553 in src/linting/extended_checks.jl

View workflow job for this annotation

GitHub Actions / run_lint

Use `thaskey(dict,key)` instead of the Julia's `haskey`. raicode/src/linting/extended_checks.jl
# In the front-end and in FFI, we are allowed to refer to `Shape`
contains(markers[:filename], "src/Compiler/Front") && return
contains(markers[:filename], "src/Compiler/front2back.jl") && return
contains(markers[:filename], "src/FFI") && return
contains(markers[:filename], "src/FrontIR") && return
# Also, allow usages in tests
contains(markers[:filename], "test/") && return

Expand All @@ -574,4 +575,4 @@
msg = "Use `Threads.@threads :dynamic` instead of `Threads.@threads :static`. Static threads must not be used as generated tasks will not be able to migrate across threads."
generic_check(t, x, "@threads :static hole_variable_star", msg)
generic_check(t, x, "Threads.@threads :static hole_variable_star", msg)
end
end
Loading