before_code stringlengths 30 149k | reviewer_comment stringlengths 16 20.6k | after_code stringlengths 30 163k | diff_context stringlengths 0 22.4k | file_path stringlengths 6 155 | comment_line int64 0 26 | language stringclasses 19
values | quality_score float64 0.07 1 | comment_type stringclasses 9
values | comment_length int64 16 20.6k | before_lines int64 2 4.61k | after_lines int64 2 4.4k | is_negative bool 2
classes | pr_title stringlengths 7 140 | pr_number int64 18 61.2k | repo_name stringclasses 29
values | repo_stars int64 321 56k | repo_language stringclasses 14
values | reviewer_username stringclasses 378
values | author_username stringclasses 739
values | user stringlengths 361 200k | assistant stringlengths 16 20.6k | system stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@noinline function _invalid_base(base)
throw(ArgumentError("invalid base: base must be 2 ≤ base ≤ 62, got $base"))
end
@noinline _invalid_digit(base, char) = throw(ArgumentError("invalid base $base digit $(repr(char))"))
function parse_char(::Type{T}, c::AbstractChar, base::Integer, throw::Bool) where {T <: Integ... | Consider allowing `parse(Float64, '1')` to work.
I did it like this in my PR:
https://github.com/JuliaLang/julia/blob/48bd70bcd8537043179440779b7b426282ff466d/base/parse.jl#L54-L68 | @noinline function _invalid_base(base)
throw(ArgumentError("invalid base: base must be 2 ≤ base ≤ 62, got $base"))
end
@noinline _invalid_digit(base, char) = throw(ArgumentError("invalid base $base digit $(repr(char))"))
function parse_char(::Type{T}, c::AbstractChar, base::Integer, throw::Bool) where T
a::UI... | @@ -38,14 +38,31 @@ julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
-function parse(::Type{T}, c::AbstractChar; base::Integer = 10) where T<:Integer
- a::Int = (base <= 36 ? 10 : 36)
- 2 <= ... | base/parse.jl | 26 | Julia | 0.571 | suggestion | 186 | 51 | 51 | false | Improve char to int parsing, and add `tryparse` method | 59,603 | JuliaLang/julia | 35,573 | Julia | cmcaine | jakobnissen | Review this pull request change.
Language: Julia
File: base/parse.jl
PR Title: Improve char to int parsing, and add `tryparse` method
BEFORE CODE: @noinline function _invalid_base(base)
throw(ArgumentError("invalid base: base must be 2 ≤ base ≤ 62, got $base"))
end
@noinline _invalid_digit(base, char) = throw(... | Consider allowing `parse(Float64, '1')` to work.
I did it like this in my PR:
https://github.com/JuliaLang/julia/blob/48bd70bcd8537043179440779b7b426282ff466d/base/parse.jl#L54-L68 | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
194
julia> parse(Int, "afc", base = 16)
2812
julia> parse(Float64, "1.2e-3")
0.0012
julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
0.32 + 4.5im
```
"""
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
@noinline function _invalid_base(base)
... | Should this use the `codepoint(c)` method rather than converting straight to UInt8? | 194
julia> parse(Int, "afc", base = 16)
2812
julia> parse(Float64, "1.2e-3")
0.0012
julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
0.32 + 4.5im
```
"""
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
@noinline function _invalid_base(base)
... | @@ -38,14 +38,31 @@ julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
-function parse(::Type{T}, c::AbstractChar; base::Integer = 10) where T<:Integer
- a::Int = (base <= 36 ? 10 : 36)
- 2 <= ... | base/parse.jl | 26 | Julia | 0.429 | question | 83 | 51 | 51 | false | Improve char to int parsing, and add `tryparse` method | 59,603 | JuliaLang/julia | 35,573 | Julia | cmcaine | jakobnissen | Review this pull request change.
Language: Julia
File: base/parse.jl
PR Title: Improve char to int parsing, and add `tryparse` method
BEFORE CODE: 194
julia> parse(Int, "afc", base = 16)
2812
julia> parse(Float64, "1.2e-3")
0.0012
julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
0.32 + 4.5im
```
"""
parse(T::Typ... | Should this use the `codepoint(c)` method rather than converting straight to UInt8? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
0.32 + 4.5im
```
"""
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
function parse(::Type{T}, c::AbstractChar; base::Integer = 10) where T<:Integer
a::Int = (base <= 36 ? 10 : 36)
2 <= base... | FYI This is equivalent to a `::T` return type annotation. |
julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
0.32 + 4.5im
```
"""
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
@noinline function _invalid_base(base)
throw(ArgumentError("invalid base: base must be 2 ≤ base ≤ 62, got $base"))
end
@noin... | @@ -38,16 +38,38 @@ julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
-function parse(::Type{T}, c::AbstractChar; base::Integer = 10) where T<:Integer
- a::Int = (base <= 36 ? 10 : 36)
- 2 <= ... | base/parse.jl | 26 | Julia | 0.5 | suggestion | 57 | 51 | 51 | false | Improve char to int parsing, and add `tryparse` method | 59,603 | JuliaLang/julia | 35,573 | Julia | LilithHafner | jakobnissen | Review this pull request change.
Language: Julia
File: base/parse.jl
PR Title: Improve char to int parsing, and add `tryparse` method
BEFORE CODE:
julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
0.32 + 4.5im
```
"""
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse ... | FYI This is equivalent to a `::T` return type annotation. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
function parse(::Type{T}, c::AbstractChar; base::Integer = 10) where T<:Integer
a::Int = (base <= 36 ? 10 : 36)
2 <= base <= 62 || throw(ArgumentError("invalid base: base must be 2 ≤ base ... | In general, I try to avoid second guessing the compiler on inlining heuristics unless I'm very familiar with the code and all its callsites and/or I've measured performance differences that confirm that I know better than the compiler.
This inlining choice seems accurate to me so I'm willing to proceed with the annota... | """
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
@noinline function _invalid_base(base)
throw(ArgumentError("invalid base: base must be 2 ≤ base ≤ 62, got $base"))
end
@noinline _invalid_digit(base, char) = throw(ArgumentError("invalid base... | @@ -38,16 +38,38 @@ julia> parse(Complex{Float64}, "3.2e-1 + 4.5im")
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
-function parse(::Type{T}, c::AbstractChar; base::Integer = 10) where T<:Integer
- a::Int = (base <= 36 ? 10 : 36)
- 2 <= ... | base/parse.jl | 26 | Julia | 0.643 | performance | 359 | 51 | 51 | false | Improve char to int parsing, and add `tryparse` method | 59,603 | JuliaLang/julia | 35,573 | Julia | LilithHafner | jakobnissen | Review this pull request change.
Language: Julia
File: base/parse.jl
PR Title: Improve char to int parsing, and add `tryparse` method
BEFORE CODE: """
parse(T::Type, str; base = Int)
parse(::Type{Union{}}, slurp...; kwargs...) = error("cannot parse a value as Union{}")
function parse(::Type{T}, c::AbstractChar; ba... | In general, I try to avoid second guessing the compiler on inlining heuristics unless I'm very familiar with the code and all its callsites and/or I've measured performance differences that confirm that I know better than the compiler.
This inlining choice seems accurate to me so I'm willing to proceed with the annota... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
struct Fix{N,F,T} <: Function
f::F
x::T
function Fix{N}(f::F, x) where {N,F}
if !(N isa Int)
throw(ArgumentError(LazyString("expected type parameter in `Fix` to be `Int`, but got `", N, "::", typeof(N), "`")))
elseif N < 1
throw(ArgumentError(LazyString("expected... | can't this all be `Base.show(io::IO, fix::Fix{N}) where {N}` ? why is this `get_n` needed | """
struct Fix{N,F,T} <: Function
f::F
x::T
function Fix{N}(f::F, x) where {N,F}
if !(N isa Int)
throw(ArgumentError(LazyString("expected type parameter in `Fix` to be `Int`, but got `", N, "::", typeof(N), "`")))
elseif N < 1
throw(ArgumentError(LazyString("expected... | @@ -1201,6 +1201,22 @@ end
(f::Fix{1})(arg; kws...) = f.f(f.x, arg; kws...)
(f::Fix{2})(arg; kws...) = f.f(arg, f.x; kws...)
+function Base.show(io::IO, fix::Fix)
+ function get_n(::Fix{N}) where {N} | base/operators.jl | 26 | Julia | 0.357 | suggestion | 89 | 51 | 51 | false | implement two-argument `show` for `Base.Fix` correctly | 59,617 | JuliaLang/julia | 35,573 | Julia | adienes | nsajko | Review this pull request change.
Language: Julia
File: base/operators.jl
PR Title: implement two-argument `show` for `Base.Fix` correctly
BEFORE CODE: """
struct Fix{N,F,T} <: Function
f::F
x::T
function Fix{N}(f::F, x) where {N,F}
if !(N isa Int)
throw(ArgumentError(LazyString("exp... | can't this all be `Base.show(io::IO, fix::Fix{N}) where {N}` ? why is this `get_n` needed | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
x::T
function Fix{N}(f::F, x) where {N,F}
if !(N isa Int)
throw(ArgumentError(LazyString("expected type parameter in `Fix` to be `Int`, but got `", N, "::", typeof(N), "`")))
elseif N < 1
throw(ArgumentError(LazyString("expected `N` in `Fix{N}` to be integer greater than... | ```suggestion
function Base.show(io::IO, fix::Fix{N}) where {N}
constr = Fix{N}
``` | x::T
function Fix{N}(f::F, x) where {N,F}
if !(N isa Int)
throw(ArgumentError(LazyString("expected type parameter in `Fix` to be `Int`, but got `", N, "::", typeof(N), "`")))
elseif N < 1
throw(ArgumentError(LazyString("expected `N` in `Fix{N}` to be integer greater than... | @@ -1201,6 +1201,22 @@ end
(f::Fix{1})(arg; kws...) = f.f(f.x, arg; kws...)
(f::Fix{2})(arg; kws...) = f.f(arg, f.x; kws...)
+function Base.show(io::IO, fix::Fix)
+ function get_n(::Fix{N}) where {N}
+ N
+ end
+ constr = Fix{get_n(fix)} | base/operators.jl | 26 | Julia | 0.571 | suggestion | 87 | 51 | 51 | false | implement two-argument `show` for `Base.Fix` correctly | 59,617 | JuliaLang/julia | 35,573 | Julia | nsajko | nsajko | Review this pull request change.
Language: Julia
File: base/operators.jl
PR Title: implement two-argument `show` for `Base.Fix` correctly
BEFORE CODE: x::T
function Fix{N}(f::F, x) where {N,F}
if !(N isa Int)
throw(ArgumentError(LazyString("expected type parameter in `Fix` to be `Int`, ... | ```suggestion
function Base.show(io::IO, fix::Fix{N}) where {N}
constr = Fix{N}
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
end
function (f::Fix{N})(args::Vararg{Any,M}; kws...) where {N,M}
M < N-1 && throw(ArgumentError(LazyString("expected at least ", N-1, " arguments to `Fix{", N, "}`, but got ", M)))
return f.f(args[begin:begin+(N-2)]..., f.x, args[begin+(N-1):end]...; kws...)
end
# Special cases for improved constant ... | Might it be cleaner just to redirect from `show(::Function)` back to show_default, so we don't need to write out an explicit hand-written copy of `show_default`, and also perhaps to define `showarg`?
```suggestion
show(io::IO, fix::Fix) = show_default(io, fix)
function showarg(io::IO, fix::Fix{N}, toplevel) where {N}
... | end
end
function (f::Fix{N})(args::Vararg{Any,M}; kws...) where {N,M}
M < N-1 && throw(ArgumentError(LazyString("expected at least ", N-1, " arguments to `Fix{", N, "}`, but got ", M)))
(left, right) = _split_tuple(args, N-1)
return f.f(left..., f.x, right...; kws...)
end
# Special cases for improved ... | @@ -1201,6 +1201,19 @@ end
(f::Fix{1})(arg; kws...) = f.f(f.x, arg; kws...)
(f::Fix{2})(arg; kws...) = f.f(arg, f.x; kws...)
+function Base.show(io::IO, fix::Fix{N}) where {N}
+ constr = Fix{N}
+ callable = fix.f
+ fixed_argument = fix.x
+ show(io, constr)
+ print(io, '(')
+ show(io, callable)
+ ... | base/operators.jl | 26 | Julia | 0.786 | suggestion | 436 | 51 | 51 | false | implement two-argument `show` for `Base.Fix` correctly | 59,617 | JuliaLang/julia | 35,573 | Julia | vtjnash | nsajko | Review this pull request change.
Language: Julia
File: base/operators.jl
PR Title: implement two-argument `show` for `Base.Fix` correctly
BEFORE CODE: end
end
function (f::Fix{N})(args::Vararg{Any,M}; kws...) where {N,M}
M < N-1 && throw(ArgumentError(LazyString("expected at least ", N-1, " arguments to `F... | Might it be cleaner just to redirect from `show(::Function)` back to show_default, so we don't need to write out an explicit hand-written copy of `show_default`, and also perhaps to define `showarg`?
```suggestion
show(io::IO, fix::Fix) = show_default(io, fix)
function showarg(io::IO, fix::Fix{N}, toplevel) where {N}
... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return 1;
#endif
}
JL_DLLEXPORT int jl_effective_threads(void) JL_NOTSAFEPOINT
{
// We want the more conservative estimate of the two.
int cpu_threads = jl_cpu_threads();
int available_parallelism = uv_available_parallelism();
return available_parallelism < cpu_threads ? available_parallelism : cpu... | What is this check? The C standard states that `environ` is required to be defined by the user (thus must not be a macro) | return 1;
#endif
}
JL_DLLEXPORT int jl_effective_threads(void) JL_NOTSAFEPOINT
{
// We want the more conservative estimate of the two.
int cpu_threads = jl_cpu_threads();
int available_parallelism = uv_available_parallelism();
return available_parallelism < cpu_threads ? available_parallelism : cpu... | @@ -496,8 +496,8 @@ JL_DLLEXPORT uint64_t jl_hrtime(void) JL_NOTSAFEPOINT
#ifdef __APPLE__
#include <crt_externs.h>
#else
-#if !defined(_OS_WINDOWS_) || defined(_COMPILER_GCC_)
-extern char **environ;
+#if (!defined(_OS_WINDOWS_) || defined(_COMPILER_GCC_)) && !defined(environ) | src/sys.c | 26 | C | 0.571 | question | 121 | 51 | 51 | false | Fix several Windows build warnings | 59,634 | JuliaLang/julia | 35,573 | Julia | vtjnash | topolarity | Review this pull request change.
Language: C
File: src/sys.c
PR Title: Fix several Windows build warnings
BEFORE CODE: return 1;
#endif
}
JL_DLLEXPORT int jl_effective_threads(void) JL_NOTSAFEPOINT
{
// We want the more conservative estimate of the two.
int cpu_threads = jl_cpu_threads();
int avail... | What is this check? The C standard states that `environ` is required to be defined by the user (thus must not be a macro) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
julia> rm("this_file_does_not_exist", force=true)
julia> rm("this_file_does_not_exist")
ERROR: IOError: unlink("this_file_does_not_exist"): no such file or directory (ENOENT)
Stacktrace:
[...]
```
"""
function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
if islink(path) || !isdir(path)
... | This looks like a race condition if multiple julia processes are running `rm` at the same time. |
julia> rm("this_file_does_not_exist", force=true)
julia> rm("this_file_does_not_exist")
ERROR: IOError: unlink("this_file_does_not_exist"): no such file or directory (ENOENT)
Stacktrace:
[...]
```
"""
function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allow_delayed_delete::Bool=true)
# al... | @@ -278,23 +278,24 @@ Stacktrace:
[...]
```
"""
-function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allow_delayed_delete::Bool=true)
- # allow_delayed_delete is used by Pkg.gc() but is otherwise not part of the public API
+function rm(path::AbstractString; force::Bool=false, recursive::Bo... | base/file.jl | 26 | Julia | 0.5 | bug | 95 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | nhz2 | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE:
julia> rm("this_file_does_not_exist", force=true)
julia> rm("this_file_does_not_exist")
ERROR: IOError: unlink("this_file_does_not_exist"): no... | This looks like a race condition if multiple julia processes are running `rm` at the same time. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# Files that were requested to be deleted but can't be by the current process
# i.e. loaded DLLs on Windows
delayed_delete_list() = joinpath(tempdir(), "julia_delayed_deletes.txt")
"""
rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
Delete the file, link, or empty directory at the given path. I... | I do not think we want this behavior for all `rm()` calls; I think we should continue to only do this behavior if `allow_delayed_delete=true`, since this is a very heavyweight and unusual behavior. In particular, getting `UV_EACCES` can happen if the file you're attempting to delete doesn't belong to your user. We do... | # Files that were requested to be deleted but can't be by the current process,
# i.e. loaded DLLs on Windows, are listed in the directory below
delayed_delete_ref() = joinpath(tempdir(), "julia_delayed_deletes_ref")
"""
rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
Delete the file, link, or e... | @@ -278,23 +278,24 @@ Stacktrace:
[...]
```
"""
-function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allow_delayed_delete::Bool=true)
- # allow_delayed_delete is used by Pkg.gc() but is otherwise not part of the public API
+function rm(path::AbstractString; force::Bool=false, recursive::Bo... | base/file.jl | 26 | Julia | 0.643 | suggestion | 532 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | staticfloat | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: # Files that were requested to be deleted but can't be by the current process
# i.e. loaded DLLs on Windows
delayed_delete_list() = joinpath(tem... | I do not think we want this behavior for all `rm()` calls; I think we should continue to only do this behavior if `allow_delayed_delete=true`, since this is a very heavyweight and unusual behavior. In particular, getting `UV_EACCES` can happen if the file you're attempting to delete doesn't belong to your user. We do... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
nothing
finally
Libc.free(req)
end
end
end
# Loaded DLLs cannot be deleted on Windows, even with posix delete mode but they can be renamed.
# delayed_delete_dll(path) does so temporarily, until later cleanup by Pkg.gc().
function delayed_delete_dll(path)
... | ```suggestion
print(io, temp_path) # record the temporary path for Pkg.gc()
``` | end
nothing
finally
Libc.free(req)
end
end
end
# Loaded DLLs cannot be deleted on Windows, even with posix delete mode but they can be renamed.
# delayed_delete_dll(path) does so temporarily, until later cleanup by Pkg.gc().
function delayed_delete_dll(path)
... | @@ -330,6 +324,27 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allo
end
+# Loaded DLLs cannot be deleted on Windows, even with posix delete mode but they can be renamed.
+# delayed_delete_dll(path) does so temporarily, until later cleanup by Pkg.gc().
+function delayed_delete_dll(... | base/file.jl | 26 | Julia | 0.571 | suggestion | 83 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: end
nothing
finally
Libc.free(req)
end
end
end
# Loaded DLLs cannot be deleted on Wind... | ```suggestion
print(io, temp_path) # record the temporary path for Pkg.gc()
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), C_NULL, req, path, C_NULL)
uv_fs_req_cleanup(req)
if ret < 0 && !(force && ret == Base.UV_ENOENT)
uv_error("rm($(repr(path)))", ret)
end
nothing
... | This is generally a very unreliable way to go about finding a safe folder to move a file to. I suggest just keeping it in the same folder
```suggestion
path = abspath(path)
deletedir = dirname(path)
``` | try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), C_NULL, req, path, C_NULL)
uv_fs_req_cleanup(req)
if ret < 0 && !(force && ret == Base.UV_ENOENT)
uv_error("rm($(repr(path)))", ret)
end
nothing
... | @@ -330,6 +324,27 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allo
end
+# Loaded DLLs cannot be deleted on Windows, even with posix delete mode but they can be renamed.
+# delayed_delete_dll(path) does so temporarily, until later cleanup by Pkg.gc().
+function delayed_delete_dll(... | base/file.jl | 26 | Julia | 0.857 | suggestion | 210 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), C_NULL, req, path, C_NULL)
uv... | This is generally a very unreliable way to go about finding a safe folder to move a file to. I suggest just keeping it in the same folder
```suggestion
path = abspath(path)
deletedir = dirname(path)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions, used to
# respectively create and remove temporary depots to use in tests.
# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
# precompilation in the... | ```suggestion
rd, wr = Base.link_pipe(true, true)
run(cmd, rd, devnull, stderr; wait=false)
Base.close_pipe_sync(rd)
``` | # This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions, used to
# respectively create and remove temporary depots to use in tests.
# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
# precompilation in the... | @@ -0,0 +1,58 @@
+# This file is a part of Julia. License is MIT: https://julialang.org/license
+
+# This includes the `mkdepottempdir` and `rmdepot` functions, used to
+# respectively create and remove temporary depots to use in tests.
+# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
+... | test/tempdepot.jl | 26 | Julia | 0.857 | suggestion | 144 | 51 | 44 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: test/tempdepot.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions... | ```suggestion
rd, wr = Base.link_pipe(true, true)
run(cmd, rd, devnull, stderr; wait=false)
Base.close_pipe_sync(rd)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions, used to
# respectively create and remove temporary depots to use in tests.
# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
# precompilation in the... | ```suggestion
eof(stdin)
``` | # This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions, used to
# respectively create and remove temporary depots to use in tests.
# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
# precompilation in the... | @@ -0,0 +1,58 @@
+# This file is a part of Julia. License is MIT: https://julialang.org/license
+
+# This includes the `mkdepottempdir` and `rmdepot` functions, used to
+# respectively create and remove temporary depots to use in tests.
+# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
+... | test/tempdepot.jl | 17 | Julia | 0.429 | suggestion | 36 | 42 | 42 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: test/tempdepot.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions... | ```suggestion
eof(stdin)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
end
catch err
(isa(err, IOError) && err.code==Base.UV_EACCES) || rethrow()
end
end
req = Libc.malloc(_sizeof_uv_fs)
try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), C_NUL... | unused variable cleanup
```suggestion
``` | end
end
catch err
(isa(err, IOError) && err.code==Base.UV_EACCES) || rethrow()
end
end
req = Libc.malloc(_sizeof_uv_fs)
try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), C_NUL... | @@ -330,6 +324,21 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allo
end
+# Loaded DLLs cannot be deleted on Windows, even with posix delete mode but they can be renamed.
+# delayed_delete_dll(path) does so temporarily, until later cleanup by Pkg.gc().
+function delayed_delete_dll(... | base/file.jl | 26 | Julia | 0.5 | suggestion | 41 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: end
end
catch err
(isa(err, IOError) && err.code==Base.UV_EACCES) || rethrow()
... | unused variable cleanup
```suggestion
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions, used to
# respectively create and remove temporary depots to use in tests.
# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
# precompilation in the... | Windows command line is very limited in how much text it can reliably transfer. Sometimes as low as 2k characters. This list should be passed via stdin to avoid the coammnd getting truncated | # This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions, used to
# respectively create and remove temporary depots to use in tests.
# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
# precompilation in the... | @@ -0,0 +1,58 @@
+# This file is a part of Julia. License is MIT: https://julialang.org/license
+
+# This includes the `mkdepottempdir` and `rmdepot` functions, used to
+# respectively create and remove temporary depots to use in tests.
+# `mktempdir` and `rm` cannot be used because, on Windows, the DLLs generated by
+... | test/tempdepot.jl | 18 | Julia | 0.429 | suggestion | 190 | 43 | 43 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: test/tempdepot.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
# This includes the `mkdepottempdir` and `rmdepot` functions... | Windows command line is very limited in how much text it can reliably transfer. Sometimes as low as 2k characters. This list should be passed via stdin to avoid the coammnd getting truncated | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
try
rm(path, force=true, recursive=true)
catch ex
@warn "Failed to clean up temporary path \$(repr(path))\n\$ex" _group=:file
end
end
"""
cmd = Cmd(Base.cmd_gen(((Base.julia_cmd(),), ("--startup-file=no",), ("-e",), (rmcmd,))); ... | ```suggestion
@lock TEMP_CLEANUP_LOCK temp_cleanup_postprocess(keys(TEMP_CLEANUP))
``` | rmcmd = """
cleanuplist = readlines(stdin) # This loop won't start running until stdin is closed, which is supposed to be sequenced after the process exits
sleep(1) # Wait for the operating system to hopefully be ready, since the OS implementation is probably incorrect, given the history of bugg... | @@ -678,8 +685,41 @@ end
# deprecated internal function used by some packages
temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
+function temp_cleanup_postprocess(cleanup_dirs)
+ if !isempty(cleanup_dirs)
+ rmcmd = """
+ ... | base/file.jl | 26 | Julia | 0.571 | suggestion | 90 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: try
rm(path, force=true, recursive=true)
catch ex
@warn "Failed to clean up temporary pa... | ```suggestion
@lock TEMP_CLEANUP_LOCK temp_cleanup_postprocess(keys(TEMP_CLEANUP))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if may_need_gc
# this is only usually required on Sys.iswindows(), but may as well do it everywhere
GC.gc(true)
end
@lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(true)
nothing
end
# deprecated internal function used by some packages
temp_cleanup_purge(; force=false) = force ? tem... | You're leaking rd handle here. Rather than fix this up though, I'd prefer switching to the fully managed API. You're right I forgot rawhandle didn't return an fd. The function I was looking for was `Base._fd` | return true
end
end
if may_need_gc
# this is only usually required on Sys.iswindows(), but may as well do it everywhere
GC.gc(true)
end
@lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(true)
nothing
end
# deprecated internal function used by some packages
tem... | @@ -678,8 +685,41 @@ end
# deprecated internal function used by some packages
temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
+function temp_cleanup_postprocess(cleanup_dirs)
+ if !isempty(cleanup_dirs)
+ rmcmd = """
+ ... | base/file.jl | 26 | Julia | 0.786 | suggestion | 208 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: if may_need_gc
# this is only usually required on Sys.iswindows(), but may as well do it everywhere
GC.gc(true)
end
... | You're leaking rd handle here. Rather than fix this up though, I'd prefer switching to the fully managed API. You're right I forgot rawhandle didn't return an fd. The function I was looking for was `Base._fd` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
function temp_cleanup_postprocess(cleanup_dirs)
if !isempty(cleanup_dirs)
rmcmd = """
eof(stdin)
for path in eachline(stdin)
try
rm(... | ```suggestion
run(cmd, pw, devnull, stderr; wait=false)
join(pw, cleanup_dirs, "\n")
Base.dup(Base._fd(pw)) # intentionally leak a reference, until the process exits
``` | end
# deprecated internal function used by some packages
temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
function temp_cleanup_postprocess(cleanup_dirs)
if !isempty(cleanup_dirs)
rmcmd = """
cleanuplist = readlines(... | @@ -678,8 +685,41 @@ end
# deprecated internal function used by some packages
temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
+function temp_cleanup_postprocess(cleanup_dirs)
+ if !isempty(cleanup_dirs)
+ rmcmd = """
+ ... | base/file.jl | 26 | Julia | 0.857 | suggestion | 193 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
function tem... | ```suggestion
run(cmd, pw, devnull, stderr; wait=false)
join(pw, cleanup_dirs, "\n")
Base.dup(Base._fd(pw)) # intentionally leak a reference, until the process exits
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
may_need_gc = false
@lock TEMP_CLEANUP_LOCK filter!(TEMP_CLEANUP) do (path, asap)
try
ispath(path) || return false
may_need_gc = true
return true
catch ex
ex isa InterruptException && rethrow()
return true
end
end
if may... | this is a no-op now, which won't be useful to you
```suggestion
``` | end
function temp_cleanup_purge_all()
may_need_gc = false
@lock TEMP_CLEANUP_LOCK filter!(TEMP_CLEANUP) do (path, asap)
try
ispath(path) || return false
may_need_gc = true
return true
catch ex
ex isa InterruptException && rethrow()
ret... | @@ -678,8 +685,41 @@ end
# deprecated internal function used by some packages
temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
+function temp_cleanup_postprocess(cleanup_dirs)
+ if !isempty(cleanup_dirs)
+ rmcmd = """
+ ... | base/file.jl | 26 | Julia | 0.643 | suggestion | 67 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: may_need_gc = false
@lock TEMP_CLEANUP_LOCK filter!(TEMP_CLEANUP) do (path, asap)
try
ispath(path) || return false
... | this is a no-op now, which won't be useful to you
```suggestion
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@lock TEMP_CLEANUP_LOCK filter!(TEMP_CLEANUP) do (path, asap)
try
ispath(path) || return false
may_need_gc = true
return true
catch ex
ex isa InterruptException && rethrow()
return true
end
end
if may_need_gc
# this ... | ```suggestion
cleanuplist = readlines(stdin) # This loop won't start running until stdin is closed, which is supposed to be sequenced after the process exits
sleep(1) # Wait for the operating system to hopefully be ready, since the OS implementation is probably incorrect, given the history of buggy work... |
function temp_cleanup_purge_all()
may_need_gc = false
@lock TEMP_CLEANUP_LOCK filter!(TEMP_CLEANUP) do (path, asap)
try
ispath(path) || return false
may_need_gc = true
return true
catch ex
ex isa InterruptException && rethrow()
return ... | @@ -678,8 +685,41 @@ end
# deprecated internal function used by some packages
temp_cleanup_purge(; force=false) = force ? temp_cleanup_purge_all() : @lock TEMP_CLEANUP_LOCK temp_cleanup_purge_prelocked(false)
+function temp_cleanup_postprocess(cleanup_dirs)
+ if !isempty(cleanup_dirs)
+ rmcmd = """
+ ... | base/file.jl | 26 | Julia | 0.929 | bug | 421 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | vtjnash | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: @lock TEMP_CLEANUP_LOCK filter!(TEMP_CLEANUP) do (path, asap)
try
ispath(path) || return false
may_need_gc =... | ```suggestion
cleanuplist = readlines(stdin) # This loop won't start running until stdin is closed, which is supposed to be sequenced after the process exits
sleep(1) # Wait for the operating system to hopefully be ready, since the OS implementation is probably incorrect, given the history of buggy work... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
req = Libc.malloc(_sizeof_uv_fs)
try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), C_NULL, req, path, C_NULL)
uv_fs_req_cleanup(req)
if ret < 0 && !(force && ret == Base.UV_ENOENT)
uv_error("rm($(repr(path))... | I suggest using `open() do io` form here, just in case the `print()` throws an error (out of space?) which would then cause us to not call `close(io)` until we eventually GC. Considering we could end up attempting to delete many files in a row and hit the same error over and over again, it'd be nice to ensure that we'... | end
req = Libc.malloc(_sizeof_uv_fs)
try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), C_NULL, req, path, C_NULL)
uv_fs_req_cleanup(req)
if ret < 0 && !(force && ret == Base.UV_ENOENT)
uv_error("rm($(repr(path))... | @@ -330,6 +324,19 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allo
end
+# Loaded DLLs cannot be deleted on Windows, even with posix delete mode but they can be renamed.
+# delayed_delete_dll(path) does so temporarily, until later cleanup by Pkg.gc().
+function delayed_delete_dll(... | base/file.jl | 26 | Julia | 0.786 | bug | 653 | 51 | 51 | false | Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL | 59,635 | JuliaLang/julia | 35,573 | Julia | staticfloat | Liozou | Review this pull request change.
Language: Julia
File: base/file.jl
PR Title: Change delayed delete mechanism to prevent cross-drive mv failure for in-use DLL
BEFORE CODE: end
req = Libc.malloc(_sizeof_uv_fs)
try
ret = ccall(:uv_fs_rmdir, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, P... | I suggest using `open() do io` form here, just in case the `print()` throws an error (out of space?) which would then cause us to not call `close(io)` until we eventually GC. Considering we could end up attempting to delete many files in a row and hit the same error over and over again, it'd be nice to ensure that we'... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#include "julia_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
jl_code_info_t *src; // contains the names and number of slots
jl_method_instance_t *mi; // MethodInstance we're executing, or NULL if toplevel
jl_code_instance_t *ci; // CodeInstance we're executing (for generated functions... | ```suggestion
JL_CC_IGNORE_START("-Wc++-compat") \
``` | #include "julia_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
jl_code_info_t *src; // contains the names and number of slots
jl_method_instance_t *mi; // MethodInstance we're executing, or NULL if toplevel
jl_code_instance_t *ci; // CodeInstance we're executing (for generated functions... | @@ -33,9 +33,9 @@ typedef struct {
var = (decltype(var))alloca((n))
#else
#define JL_CPPALLOCA(var,n) \
- JL_GCC_IGNORE_START("-Wc++-compat") \
+ JL_CC_IGNORE_START("-Wc++-compat") ... | src/interpreter.c | 26 | C | 0.714 | suggestion | 103 | 51 | 51 | false | Fix clang 21 warnings | 59,638 | JuliaLang/julia | 35,573 | Julia | fingolfin | gbaraldi | Review this pull request change.
Language: C
File: src/interpreter.c
PR Title: Fix clang 21 warnings
BEFORE CODE: #include "julia_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
jl_code_info_t *src; // contains the names and number of slots
jl_method_instance_t *mi; // MethodInstance we'... | ```suggestion
JL_CC_IGNORE_START("-Wc++-compat") \
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@test occursin("where {T2<:Integer, T1<:T2}", repr)
end
struct S45879{P} end
let ms = methods(S45879)
@test ms isa Base.MethodList
@test length(ms) == 0
@test sprint(show, Base.MethodList(Method[], typeof(S45879).name)) isa String
end
function f49475(a=12.0; b) end
let ms = methods(f49475)
@test l... | ```suggestion
@test isconcretetype(Base.infer_return_type(Base.url))
```
No need to be fancy here. | @test occursin("where {T2<:Integer, T1<:T2}", repr)
end
struct S45879{P} end
let ms = methods(S45879)
@test ms isa Base.MethodList
@test length(ms) == 0
@test sprint(show, Base.MethodList(Method[], typeof(S45879).name)) isa String
end
function f49475(a=12.0; b) end
let ms = methods(f49475)
@test l... | @@ -877,6 +877,10 @@ else
@test occursin("https://github.com/JuliaLang/julia/tree/$(Base.GIT_VERSION_INFO.commit)/base/special/trig.jl#L", Base.url(which(sin, (Float64,))))
end
+@testset "method show: method url return type inference" begin
+ @test (isconcretetype ∘ Base.infer_return_type)(Base.url) | test/show.jl | 26 | Julia | 0.857 | suggestion | 102 | 51 | 51 | false | type stability fixes for `Base.url` | 59,647 | JuliaLang/julia | 35,573 | Julia | LilithHafner | nsajko | Review this pull request change.
Language: Julia
File: test/show.jl
PR Title: type stability fixes for `Base.url`
BEFORE CODE: @test occursin("where {T2<:Integer, T1<:T2}", repr)
end
struct S45879{P} end
let ms = methods(S45879)
@test ms isa Base.MethodList
@test length(ms) == 0
@test sprint(show, ... | ```suggestion
@test isconcretetype(Base.infer_return_type(Base.url))
```
No need to be fancy here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
fneg = !fneg
else
fu = fu - du
end
else
if fumax - fu < du
fu = fumax
else
fu = fu + du
end
end
end
if fneg
fu |= sign_mask(F)
end
reinterpret(F, fu)
end
"... | Seems not necessary to have an `Unsigned`-specific method.
```suggestion
``` | fneg = !fneg
else
fu = fu - du
end
else
if fumax - fu < du
fu = fumax
else
fu = fu + du
end
end
end
if fneg
fu |= sign_mask(F)
end
reinterpret(F, fu)
end
"... | @@ -851,6 +844,15 @@ function nextfloat(f::IEEEFloat, d::Integer)
reinterpret(F, fu)
end
+"""
+ nextfloat(x::AbstractFloat, n::Integer)
+
+The result of `n` iterative applications of `nextfloat` to `x` if `n >= 0`, or `-n`
+applications of [`prevfloat`](@ref) if `n < 0`.
+"""
+nextfloat(f::AbstractFloat, d::... | base/float.jl | 26 | Julia | 0.571 | suggestion | 78 | 51 | 51 | false | fix overflow in `prevfloat` with unsigned stepcount | 59,668 | JuliaLang/julia | 35,573 | Julia | nsajko | adienes | Review this pull request change.
Language: Julia
File: base/float.jl
PR Title: fix overflow in `prevfloat` with unsigned stepcount
BEFORE CODE: fneg = !fneg
else
fu = fu - du
end
else
if fumax - fu < du
fu = fumax
... | Seems not necessary to have an `Unsigned`-specific method.
```suggestion
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
fu = min(fumax, du - fu)
fneg = !fneg
else
fu = fu - du
end
else
if fumax - fu < du
fu = fumax
else
fu = fu + du
end
end
end
if fneg
fu |= sign_mask... | Why define a method for `AbstractFloat` which is just going to throw `MethodError` for non-`IEEEFloat`? Better just define it for `IEEEFloat`.
```suggestion
nextfloat(f::IEEEFloat, d::Integer) = _nextfloat(f, d < 0, uabs(d))
``` | fu = min(fumax, du - fu)
fneg = !fneg
else
fu = fu - du
end
else
if fumax - fu < du
fu = fumax
else
fu = fu + du
end
end
end
if fneg
fu |= sign_mask... | @@ -851,6 +844,15 @@ function nextfloat(f::IEEEFloat, d::Integer)
reinterpret(F, fu)
end
+"""
+ nextfloat(x::AbstractFloat, n::Integer)
+
+The result of `n` iterative applications of `nextfloat` to `x` if `n >= 0`, or `-n`
+applications of [`prevfloat`](@ref) if `n < 0`.
+"""
+nextfloat(f::AbstractFloat, d::... | base/float.jl | 26 | Julia | 1 | refactor | 229 | 51 | 51 | false | fix overflow in `prevfloat` with unsigned stepcount | 59,668 | JuliaLang/julia | 35,573 | Julia | nsajko | adienes | Review this pull request change.
Language: Julia
File: base/float.jl
PR Title: fix overflow in `prevfloat` with unsigned stepcount
BEFORE CODE: fu = min(fumax, du - fu)
fneg = !fneg
else
fu = fu - du
end
else
if fumax - fu <... | Why define a method for `AbstractFloat` which is just going to throw `MethodError` for non-`IEEEFloat`? Better just define it for `IEEEFloat`.
```suggestion
nextfloat(f::IEEEFloat, d::Integer) = _nextfloat(f, d < 0, uabs(d))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
nextfloat(x::AbstractFloat, n::Integer)
The result of `n` iterative applications of `nextfloat` to `x` if `n >= 0`, or `-n`
applications of [`prevfloat`](@ref) if `n < 0`.
"""
nextfloat(f::AbstractFloat, d::Integer) = _nextfloat(f, d < 0, uabs(d))
nextfloat(f::IEEEFloat, d::Unsigned) = _nextfloat(f, false, d)
... | ```suggestion
prevfloat(x::IEEEFloat, d::Integer) = _nextfloat(x, d > 0, uabs(d))
``` | """
nextfloat(x::AbstractFloat, n::Integer)
The result of `n` iterative applications of `nextfloat` to `x` if `n >= 0`, or `-n`
applications of [`prevfloat`](@ref) if `n < 0`.
"""
nextfloat(f::AbstractFloat, d::Integer) = _nextfloat(f, isnegative(d), uabs(d))
"""
nextfloat(x::AbstractFloat)
Return the smalle... | @@ -859,23 +861,23 @@ If no such `y` exists (e.g. if `x` is `Inf` or `NaN`), then return `x`.
See also: [`prevfloat`](@ref), [`eps`](@ref), [`issubnormal`](@ref).
"""
-nextfloat(x::AbstractFloat) = nextfloat(x,1)
+nextfloat(x::AbstractFloat) = nextfloat(x, 1)
"""
prevfloat(x::AbstractFloat, n::Integer)
T... | base/float.jl | 26 | Julia | 0.571 | suggestion | 85 | 51 | 51 | false | fix overflow in `prevfloat` with unsigned stepcount | 59,668 | JuliaLang/julia | 35,573 | Julia | nsajko | adienes | Review this pull request change.
Language: Julia
File: base/float.jl
PR Title: fix overflow in `prevfloat` with unsigned stepcount
BEFORE CODE: """
nextfloat(x::AbstractFloat, n::Integer)
The result of `n` iterative applications of `nextfloat` to `x` if `n >= 0`, or `-n`
applications of [`prevfloat`](@ref) if ... | ```suggestion
prevfloat(x::IEEEFloat, d::Integer) = _nextfloat(x, d > 0, uabs(d))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
end
if fneg
fu |= sign_mask(F)
end
reinterpret(F, fu)
end
"""
nextfloat(x::AbstractFloat)
Return the smallest floating point number `y` of the same type as `x` such that `x < y`.
If no such `y` exists (e.g. if `x` is `Inf` or `NaN`), then return `x`.
See also: [`prevfloat`](@r... | Now packages defining custom `AbstractFloat` are expected to define a method for `Base._nextfloat`? |
"""
nextfloat(x::AbstractFloat, n::Integer)
The result of `n` iterative applications of `nextfloat` to `x` if `n >= 0`, or `-n`
applications of [`prevfloat`](@ref) if `n < 0`.
"""
nextfloat(f::AbstractFloat, d::Integer) = _nextfloat(f, isnegative(d), uabs(d))
"""
nextfloat(x::AbstractFloat)
Return the small... | @@ -859,23 +860,23 @@ If no such `y` exists (e.g. if `x` is `Inf` or `NaN`), then return `x`.
See also: [`prevfloat`](@ref), [`eps`](@ref), [`issubnormal`](@ref).
"""
-nextfloat(x::AbstractFloat) = nextfloat(x,1)
+nextfloat(x::AbstractFloat) = nextfloat(x, 1)
"""
prevfloat(x::AbstractFloat, n::Integer)
T... | base/float.jl | 26 | Julia | 0.357 | refactor | 99 | 51 | 51 | false | fix overflow in `prevfloat` with unsigned stepcount | 59,668 | JuliaLang/julia | 35,573 | Julia | giordano | adienes | Review this pull request change.
Language: Julia
File: base/float.jl
PR Title: fix overflow in `prevfloat` with unsigned stepcount
BEFORE CODE: end
end
if fneg
fu |= sign_mask(F)
end
reinterpret(F, fu)
end
"""
nextfloat(x::AbstractFloat)
Return the smallest floating point numbe... | Now packages defining custom `AbstractFloat` are expected to define a method for `Base._nextfloat`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
!!! note
Bézout coefficients are *not* uniquely defined. `gcdx` returns the minimal
Bézout coefficients that are computed by the extended Euclidean algorithm.
(Ref: D. Knuth, TAoCP, 2/e, p. 325, Algorithm X.)
For signed integers, these coefficients `u` and `v` are minimal in
the sense that ``|u| < ... | Wouldn't it be better / fit more with the rest of the code to use this:
```suggestion
while !iszero(b)
``` |
!!! note
Bézout coefficients are *not* uniquely defined. `gcdx` returns the minimal
Bézout coefficients that are computed by the extended Euclidean algorithm.
(Ref: D. Knuth, TAoCP, 2/e, p. 325, Algorithm X.)
For signed integers, these coefficients `u` and `v` are minimal in
the sense that ``|u| < ... | @@ -223,22 +229,26 @@ julia> gcdx(15, 12, 20)
their `typemax`, and the identity then holds only via the unsigned
integers' modulo arithmetic.
"""
-Base.@assume_effects :terminates_locally function gcdx(a::Integer, b::Integer)
- T = promote_type(typeof(a), typeof(b))
- a == b == 0 && return (zero(T), ze... | base/intfuncs.jl | 26 | Julia | 0.786 | suggestion | 113 | 51 | 51 | false | clear up several more inconsistencies among `gcd` , `gcdx` and `invmod` | 59,678 | JuliaLang/julia | 35,573 | Julia | fingolfin | adienes | Review this pull request change.
Language: Julia
File: base/intfuncs.jl
PR Title: clear up several more inconsistencies among `gcd` , `gcdx` and `invmod`
BEFORE CODE:
!!! note
Bézout coefficients are *not* uniquely defined. `gcdx` returns the minimal
Bézout coefficients that are computed by the extended Eu... | Wouldn't it be better / fit more with the rest of the code to use this:
```suggestion
while !iszero(b)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
the signs of `u` and `v` are chosen so that `d` is positive.
For unsigned integers, the coefficients `u` and `v` might be near
their `typemax`, and the identity then holds only via the unsigned
integers' modulo arithmetic.
"""
Base.@assume_effects :terminates_locally function gcdx(a::T, b::T) where {T<:... | ```suggestion
# for cases like abs(Int8(-128))
if isnegative(a) && isnegative(abs(a))
``` | the signs of `u` and `v` are chosen so that `d` is positive.
For unsigned integers, the coefficients `u` and `v` might be near
their `typemax`, and the identity then holds only via the unsigned
integers' modulo arithmetic.
"""
Base.@assume_effects :terminates_locally function gcdx(a::T, b::T) where {T<:... | @@ -248,7 +248,11 @@ Base.@assume_effects :terminates_locally function gcdx(a::T, b::T) where {T<:Int
s0, s1 = s1, s0 - q*s1
t0, t1 = t1, t0 - q*t1
end
- a < 0 ? (checked_abs(a), -s0, -t0) : (a, s0, t0)
+ if isnegative(a) && isnegative(abs(a)) | base/intfuncs.jl | 26 | Julia | 0.714 | suggestion | 100 | 51 | 51 | false | clear up several more inconsistencies among `gcd` , `gcdx` and `invmod` | 59,678 | JuliaLang/julia | 35,573 | Julia | Seelengrab | adienes | Review this pull request change.
Language: Julia
File: base/intfuncs.jl
PR Title: clear up several more inconsistencies among `gcd` , `gcdx` and `invmod`
BEFORE CODE: the signs of `u` and `v` are chosen so that `d` is positive.
For unsigned integers, the coefficients `u` and `v` might be near
their `typ... | ```suggestion
# for cases like abs(Int8(-128))
if isnegative(a) && isnegative(abs(a))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for i in 1:498
@eval g54131(::Val{$i}) = i
end
g54131(::Val{499}; kwarg=true) = 499*kwarg
struct F54131; end
Base.getproperty(::F54131, ::Symbol) = Any[cos, sin, g54131][rand(1:3)]
f54131 = F54131()
@testset "performance of kwarg completion with large method tables" begin
# The goal here is to simply ensure we ... | Testing elapsed time on CI to 1 second precision is not okay (it makes CI and debugging unreliable)
```suggestion
@test (@elapsed completions(s, lastindex(s), @__MODULE__, false)) < 100
``` | for i in 1:498
@eval g54131(::Val{$i}) = i
end
g54131(::Val{499}; kwarg=true) = 499*kwarg
struct F54131; end
Base.getproperty(::F54131, ::Symbol) = Any[cos, sin, g54131][rand(1:3)]
f54131 = F54131()
@testset "performance of kwarg completion with large method tables" begin
# The goal here is to simply ensure we ... | @@ -2687,10 +2687,56 @@ f54131 = F54131()
s = "f54131.x(kwa"
a, b, c = completions(s, lastindex(s), @__MODULE__, false)
- @test_broken REPLCompletions.KeywordArgumentCompletion("kwarg") in a
+ @test REPLCompletions.KeywordArgumentCompletion("kwarg") in a
@test (@elapsed completions(s, lastindex(s... | stdlib/REPL/test/replcompletions.jl | 26 | Julia | 0.857 | bug | 193 | 51 | 51 | false | Remove restrictions on kwarg tab completion | 59,692 | JuliaLang/julia | 35,573 | Julia | vtjnash | mbauman | Review this pull request change.
Language: Julia
File: stdlib/REPL/test/replcompletions.jl
PR Title: Remove restrictions on kwarg tab completion
BEFORE CODE: for i in 1:498
@eval g54131(::Val{$i}) = i
end
g54131(::Val{499}; kwarg=true) = 499*kwarg
struct F54131; end
Base.getproperty(::F54131, ::Symbol) = Any[co... | Testing elapsed time on CI to 1 second precision is not okay (it makes CI and debugging unreliable)
```suggestion
@test (@elapsed completions(s, lastindex(s), @__MODULE__, false)) < 100
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
"""
Low level module for mmap (memory mapping of files).
"""
module Mmap
import Base: OS_HANDLE, INVALID_OS_HANDLE
export mmap
PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ()... | @vtjnash is
```suggestion
const PAGESIZE = OncePerProcess{Int}() do
Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ()))
end
```
the right way to do this on `master`? | # This file is a part of Julia. License is MIT: https://julialang.org/license
"""
Low level module for mmap (memory mapping of files).
"""
module Mmap
import Base: OS_HANDLE, INVALID_OS_HANDLE
using Base.Sys: PAGESIZE
export mmap
# for mmaps not backed by files
mutable struct Anonymous <: IO
name::String
re... | @@ -9,7 +9,7 @@ import Base: OS_HANDLE, INVALID_OS_HANDLE
export mmap
-const PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ()))
+PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ())) | stdlib/Mmap/src/Mmap.jl | 12 | Julia | 0.786 | question | 220 | 37 | 37 | false | Mmap fix on system with 64k pagesize. | 59,695 | JuliaLang/julia | 35,573 | Julia | giordano | green-br | Review this pull request change.
Language: Julia
File: stdlib/Mmap/src/Mmap.jl
PR Title: Mmap fix on system with 64k pagesize.
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
"""
Low level module for mmap (memory mapping of files).
"""
module Mmap
import Base: OS_HANDLE,... | @vtjnash is
```suggestion
const PAGESIZE = OncePerProcess{Int}() do
Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ()))
end
```
the right way to do this on `master`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# for large n, we grow at O(n/8)
# and as we reach O(memory) for memory>>1MB,
# this means we end by adding about 10% of memory each time
exp2 = sizeof(maxsize) * 8 - Core.Intrinsics.ctlz_int(maxsize)
maxsize += (1 << div(exp2 * 7, 8)) * 4 + div(maxsize, 8)
return maxsize
end
array_new_memory(m... | This isn't quite strict enough. We want to ensure that we only move the start of the array if there remains proportional space at both ends of the array (since otherwise you are signing up for potential quadratic behavior) | # and as we reach O(memory) for memory>>1MB,
# this means we end by adding about 10% of memory each time
# most commonly, this will take steps of 0-3-9-34 or 1-4-16-66 or 2-8-33
exp2 = sizeof(maxsize) * 8 - Core.Intrinsics.ctlz_int(maxsize)
maxsize += (1 << div(exp2 * 7, 8)) * 3 + div(maxsize, 8)
... | @@ -1110,22 +1110,23 @@ function _growbeg_internal!(a::Vector, delta::Int, len::Int)
if offset + len - 1 > memlen || offset < 1
throw(ConcurrencyViolationError("Vector has invalid state. Don't modify internal fields incorrectly, or resize without correct locks"))
end
- # since we will allocate the... | base/array.jl | 26 | Julia | 0.5 | suggestion | 222 | 51 | 51 | false | array: avoid overallocation when inserting at beginning of empty arrays | 59,717 | JuliaLang/julia | 35,573 | Julia | oscardssmith | vtjnash | Review this pull request change.
Language: Julia
File: base/array.jl
PR Title: array: avoid overallocation when inserting at beginning of empty arrays
BEFORE CODE: # for large n, we grow at O(n/8)
# and as we reach O(memory) for memory>>1MB,
# this means we end by adding about 10% of memory each time
... | This isn't quite strict enough. We want to ensure that we only move the start of the array if there remains proportional space at both ends of the array (since otherwise you are signing up for potential quadratic behavior) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@warn "Could not write file."
end
```
or, when the file cannot be read into a variable:
```julia
lines = try
open("/danger", "r") do f
readlines(f)
end
catch
@warn "File not found."
end
```
The syntax `catch e` (where `e` is any variable) assigns the thrown
exception object to the given varia... | I don't think `IOError` is exported (and maybe not even `public`). | @warn "Could not write file."
end
```
or, when the file cannot be read into a variable:
```julia
lines = try
open("/danger", "r") do f
readlines(f)
end
catch
@warn "File not found."
end
```
The syntax `catch e` (where `e` is any variable) assigns the thrown
exception object to the given varia... | @@ -1063,6 +1063,20 @@ end
The syntax `catch e` (where `e` is any variable) assigns the thrown
exception object to the given variable within the `catch` block.
+```julia
+try
+ a_dangerous_operation()
+catch e
+ if isa(e, EOFError)
+ @warn "The operation failed - EOF."
+ elseif isa(e, IOError) | base/docs/basedocs.jl | 26 | Julia | 0.5 | suggestion | 66 | 51 | 51 | false | Demonstrate `rethrow()` as best practice in try/catch docs | 59,729 | JuliaLang/julia | 35,573 | Julia | KristofferC | BioTurboNick | Review this pull request change.
Language: Julia
File: base/docs/basedocs.jl
PR Title: Demonstrate `rethrow()` as best practice in try/catch docs
BEFORE CODE: @warn "Could not write file."
end
```
or, when the file cannot be read into a variable:
```julia
lines = try
open("/danger", "r") do f
read... | I don't think `IOError` is exported (and maybe not even `public`). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
"""
startswith(s::AbstractString, prefix::Regex)
Return `true` if `s` starts with the regex pattern, `prefix`.
!!! note
`startswith` does not compile the anchoring into the regular
expression, but instead passes the anchoring as
`match_option` to PCRE. If compile time is amortized,
`occursin(... | Adding `match` is a good idea, though it just needs to be added to the existing see also section above.
Same for the `endswith` docstring below | end
"""
startswith(s::AbstractString, prefix::Regex)
Return `true` if `s` starts with the regex pattern, `prefix`.
!!! note
`startswith` does not compile the anchoring into the regular
expression, but instead passes the anchoring as
`match_option` to PCRE. If compile time is amortized,
`occursin(... | @@ -334,6 +334,9 @@ See also [`occursin`](@ref) and [`endswith`](@ref).
julia> startswith("JuliaLang", r"Julia|Romeo")
true
```
+# See also
+[`endswith`](@ref), [`occursin`](@ref), [`match`](@ref)
+ | base/regex.jl | 26 | Julia | 0.5 | suggestion | 144 | 51 | 51 | false | Add 'See also' sections to regex function docstring | 59,744 | JuliaLang/julia | 35,573 | Julia | LilithHafner | GianmarcoCuppari | Review this pull request change.
Language: Julia
File: base/regex.jl
PR Title: Add 'See also' sections to regex function docstring
BEFORE CODE: end
"""
startswith(s::AbstractString, prefix::Regex)
Return `true` if `s` starts with the regex pattern, `prefix`.
!!! note
`startswith` does not compile the anc... | Adding `match` is a good idea, though it just needs to be added to the existing see also section above.
Same for the `endswith` docstring below | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
errmsg = String(take!(get(IOBuffer, std_outputs, pkg_config)))
delete!(std_outputs, pkg_config) # so it's not shown as warnings, given error report
failed_deps[pkg_config] = (strict || is_project_dep) ? string(sprint(showerr... | Based on a bit of Claude.. I think this sounds reasonable:
```suggestion
loadable_exts = haskey(ext_to_parent, pkg) ? filter((dep)->haskey(ext_to_parent, dep), triggers[pkg]) : nothing
```
For an extension `ext`, `triggers[ext]` contains all triggers (including parent + trigger packages)... | end
if !circular && is_stale
Base.acquire(parallel_limiter)
is_serial_dep = pkg in serial_deps
is_project_dep = pkg in project_deps
# std monitoring
std_pipe =... | @@ -1035,7 +1112,13 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}},
end
# for extensions, any extension in our direct dependencies is one we have a right to load
# for packages, we may load any extension (all ... | base/precompilation.jl | 26 | Julia | 0.786 | suggestion | 459 | 51 | 51 | false | precompile: fail in (closer to) linear time and linear error messages | 59,765 | JuliaLang/julia | 35,573 | Julia | IanButterworth | vtjnash | Review this pull request change.
Language: Julia
File: base/precompilation.jl
PR Title: precompile: fail in (closer to) linear time and linear error messages
BEFORE CODE: errmsg = String(take!(get(IOBuffer, std_outputs, pkg_config)))
delete!(std_output... | Based on a bit of Claude.. I think this sounds reasonable:
```suggestion
loadable_exts = haskey(ext_to_parent, pkg) ? filter((dep)->haskey(ext_to_parent, dep), triggers[pkg]) : nothing
```
For an extension `ext`, `triggers[ext]` contains all triggers (including parent + trigger packages)... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
print(io, ']')
end
end
Experimental.show_error_hints(io, ex)
end
function showerror(io::IO, ex::TypeError)
print(io, "TypeError: ")
if ex.expected === Bool
print(io, "non-boolean (", typeof(ex.got), ") used in boolean context")
elseif ex.func === :var"dic... | I do not like assuming that `br.globalref` is reliable, since it both often has the wrong module (it is often the resolved value instead of the original one) and it assumes that every Binding must have been associated with one GlobalRef, but we might want to have Bindings which are not just equivalent to a GlobalRef. | end
print(io, ']')
end
end
Experimental.show_error_hints(io, ex)
end
function showerror(io::IO, ex::TypeError)
print(io, "TypeError: ")
if ex.expected === Bool
print(io, "non-boolean (", typeof(ex.got), ") used in boolean context")
elseif ex.func === :var"dic... | @@ -91,6 +91,9 @@ function showerror(io::IO, ex::TypeError)
end
if ex.context == ""
ctx = "in $(ex.func)"
+ elseif isa(ex.context, Core.Binding)
+ gr = ex.context.globalref
+ ctx = "in $(ex.func) of global binding `$(gr.mod).$(gr.name)`" | base/errorshow.jl | 26 | Julia | 0.643 | bug | 318 | 51 | 51 | false | Align interpreter and codegen error behavior of setglobal! and friends | 59,766 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: Julia
File: base/errorshow.jl
PR Title: Align interpreter and codegen error behavior of setglobal! and friends
BEFORE CODE: end
print(io, ']')
end
end
Experimental.show_error_hints(io, ex)
end
function showerror(io::IO, ex::TypeErro... | I do not like assuming that `br.globalref` is reliable, since it both often has the wrong module (it is often the resolved value instead of the original one) and it assumes that every Binding must have been associated with one GlobalRef, but we might want to have Bindings which are not just equivalent to a GlobalRef. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
jl_exceptionf(jl_argumenterror_type, "%s: too few arguments (expected %d)", fname, min);
}
JL_DLLEXPORT void JL_NORETURN jl_too_many_args(const char *fname, int max)
{
jl_exceptionf(jl_argumenterror_type, "%s: too many arguments (expected %d)", fname, max);
}
// with function name / location description, plus... | Missing GC pushes here (the correctness of your annotations is not checked in this file) | jl_exceptionf(jl_argumenterror_type, "%s: too few arguments (expected %d)", fname, min);
}
JL_DLLEXPORT void JL_NORETURN jl_too_many_args(const char *fname, int max)
{
jl_exceptionf(jl_argumenterror_type, "%s: too many arguments (expected %d)", fname, max);
}
// with function name / location description, plus... | @@ -121,6 +121,16 @@ JL_DLLEXPORT void JL_NORETURN jl_type_error_rt(const char *fname, const char *co
jl_throw(ex);
}
+JL_DLLEXPORT void JL_NORETURN jl_type_error_global(const char *fname, jl_module_t *mod, jl_sym_t *sym,
+ jl_value_t *expected JL_MAYBE_UNROOTED,
+ ... | src/rtutils.c | 26 | C | 0.214 | suggestion | 88 | 51 | 51 | false | Align interpreter and codegen error behavior of setglobal! and friends | 59,766 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: C
File: src/rtutils.c
PR Title: Align interpreter and codegen error behavior of setglobal! and friends
BEFORE CODE: jl_exceptionf(jl_argumenterror_type, "%s: too few arguments (expected %d)", fname, min);
}
JL_DLLEXPORT void JL_NORETURN jl_too_many_args(const char *fn... | Missing GC pushes here (the correctness of your annotations is not checked in this file) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
size_t page_size = jl_getpagesize(); /* jl_page_size is not set yet when loading sysimg */
size_t aligned_size = LLT_ALIGN(image->size, page_size);
#if defined(_OS_WINDOWS_)
size_t large_page_size = GetLargePageMinimum();
if (image->size > 4 * large_page_size) {
size_t aligned_size = LLT_ALIGN(i... | 256 bytes seems a bit conservative - maybe double it?
Also looking at the implementation of `win32_formatmessage`, it looks like it leaves `err_buf` mostly uninitialized if the buffer is too small. That could probably do with a quick fix-up. | size_t page_size = jl_getpagesize(); /* jl_page_size is not set yet when loading sysimg */
size_t aligned_size = LLT_ALIGN(image->size, page_size);
int fail = 0;
#if defined(_OS_WINDOWS_)
size_t large_page_size = GetLargePageMinimum();
image->data = NULL;
if (large_page_size > 0 && image->size >... | @@ -3534,23 +3534,37 @@ JL_DLLEXPORT void jl_image_unpack_zstd(void *handle, jl_image_buf_t *image)
image->size = ZSTD_getFrameContentSize(data, *plen);
size_t page_size = jl_getpagesize(); /* jl_page_size is not set yet when loading sysimg */
size_t aligned_size = LLT_ALIGN(image->size, page_size);
+ ... | src/staticdata.c | 26 | C | 0.643 | style | 244 | 51 | 51 | false | Handle errors in jl_image_unpack_zstd better, especially on Windows | 59,773 | JuliaLang/julia | 35,573 | Julia | topolarity | xal-0 | Review this pull request change.
Language: C
File: src/staticdata.c
PR Title: Handle errors in jl_image_unpack_zstd better, especially on Windows
BEFORE CODE: size_t page_size = jl_getpagesize(); /* jl_page_size is not set yet when loading sysimg */
size_t aligned_size = LLT_ALIGN(image->size, page_size);
#... | 256 bytes seems a bit conservative - maybe double it?
Also looking at the implementation of `win32_formatmessage`, it looks like it leaves `err_buf` mostly uninitialized if the buffer is too small. That could probably do with a quick fix-up. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
static DWORD WINAPI profile_bt( LPVOID lparam )
{
// Note: illegal to use jl_* functions from this thread except for profiling-specific functions
while (1) {
DWORD timeout_ms = nsecprof / (GIGA / 1000);
Sleep(timeout_ms > 0 ? timeout_ms : 1);
if (profile_running) {
if (jl_p... | What guarantees that we hold (or don't need) the lock during this `rec_backtrace_ctx` call? | static DWORD WINAPI profile_bt( LPVOID lparam )
{
// Note: illegal to use jl_* functions from this thread except for profiling-specific functions
while (1) {
DWORD timeout_ms = nsecprof / (GIGA / 1000);
Sleep(timeout_ms > 0 ? timeout_ms : 1);
if (profile_running) {
if (jl_pro... | @@ -477,17 +475,15 @@ static DWORD WINAPI profile_bt( LPVOID lparam )
}
else {
// TODO: bring this up to parity with other OS by adding loop over tid here
- jl_lock_stackwalk();
- CONTEXT ctxThread;
- if (!jl_thread_suspend_and_get_... | src/signals-win.c | 26 | C | 0.357 | question | 91 | 51 | 51 | false | signals: acquire loader lock during stackwalk on Win32 | 59,840 | JuliaLang/julia | 35,573 | Julia | topolarity | vtjnash | Review this pull request change.
Language: C
File: src/signals-win.c
PR Title: signals: acquire loader lock during stackwalk on Win32
BEFORE CODE:
static DWORD WINAPI profile_bt( LPVOID lparam )
{
// Note: illegal to use jl_* functions from this thread except for profiling-specific functions
while (1) {
... | What guarantees that we hold (or don't need) the lock during this `rec_backtrace_ctx` call? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
not call `wait()` on any tasks within the on load callback.
"""
mutable struct LazyLibrary
# Name and flags to open with
const path
const flags::UInt32
# Dependencies that must be loaded before we can load
#
# The OncePerProcess is introduced here so that any registered dependencies are
# a... | When you say other tasks, you mean other `dlopen()` tasks, right? Not all tasks? | end
(init::InitialDependencies)() = copy(init.dependencies)
"""
LazyLibrary(name; flags = <default dlopen flags>,
dependencies = LazyLibrary[], on_load_callback = nothing)
Represents a lazily-loaded shared library that delays loading itself and its dependencies
until first use in a `ccall()`, `@cc... | @@ -347,34 +354,76 @@ end
Base.string(::PrivateShlibdirGetter) = private_shlibdir()
"""
- BundledLazyLibraryPath
+ BundledLazyLibraryPath(subpath)
-Helper type for lazily constructed library paths that are stored within the
-bundled Julia distribution, primarily for use by Base modules.
+Helper type for laz... | base/libdl.jl | 26 | Julia | 0.357 | question | 81 | 51 | 51 | false | Libdl: Add documentation for LazyLibrary and friends | 59,841 | JuliaLang/julia | 35,573 | Julia | staticfloat | vtjnash | Review this pull request change.
Language: Julia
File: base/libdl.jl
PR Title: Libdl: Add documentation for LazyLibrary and friends
BEFORE CODE: not call `wait()` on any tasks within the on load callback.
"""
mutable struct LazyLibrary
# Name and flags to open with
const path
const flags::UInt32
# ... | When you say other tasks, you mean other `dlopen()` tasks, right? Not all tasks? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
end
end
```
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia> Hinter.only_int(1.0)
ERROR: MethodError: no method matching only_int(::Float64)
The function `only_int` exists, but no method is defined fo... | ```suggestion
list = get!(Vector{Any}, _hint_handlers, typename(exct))
``` | end
end
end
```
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia> Hinter.only_int(1.0)
ERROR: MethodError: no method matching only_int(::Float64)
The function `only_int` exists, but no method is defined fo... | @@ -295,18 +295,18 @@ Closest candidates are:
`if isdefined(Base.Experimental, :register_error_hint) ... end` block.
"""
function register_error_hint(@nospecialize(handler), @nospecialize(exct::Type))
- list = get!(Vector{Any}, _hint_handlers, exct)
+ list = get!(Vector{Any}, _hint_handlers, nameof(exct)) | base/experimental.jl | 26 | Julia | 0.714 | suggestion | 80 | 51 | 51 | false | fix: trigger error hints on exception supertypes too | 59,843 | JuliaLang/julia | 35,573 | Julia | vtjnash | gdalle | Review this pull request change.
Language: Julia
File: base/experimental.jl
PR Title: fix: trigger error hints on exception supertypes too
BEFORE CODE: end
end
end
```
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the h... | ```suggestion
list = get!(Vector{Any}, _hint_handlers, typename(exct))
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia> Hinter.only_int(1.0)
ERROR: MethodError: no method matching only_int(::Float64)
The function `only_int` exists, but no method is defined for this combination of argument types.
Did ... | ```suggestion
const _hint_handlers = IdDict{Typename,Vector{Any}}()
``` |
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia> Hinter.only_int(1.0)
ERROR: MethodError: no method matching only_int(::Float64)
The function `only_int` exists, but no method is defined for this combination of argument types.
Did ... | @@ -295,18 +295,18 @@ Closest candidates are:
`if isdefined(Base.Experimental, :register_error_hint) ... end` block.
"""
function register_error_hint(@nospecialize(handler), @nospecialize(exct::Type))
- list = get!(Vector{Any}, _hint_handlers, exct)
+ list = get!(Vector{Any}, _hint_handlers, nameof(exct))
... | base/experimental.jl | 26 | Julia | 0.714 | suggestion | 73 | 51 | 51 | false | fix: trigger error hints on exception supertypes too | 59,843 | JuliaLang/julia | 35,573 | Julia | vtjnash | gdalle | Review this pull request change.
Language: Julia
File: base/experimental.jl
PR Title: fix: trigger error hints on exception supertypes too
BEFORE CODE:
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia> Hinter.only_int(1.0)
ERRO... | ```suggestion
const _hint_handlers = IdDict{Typename,Vector{Any}}()
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"""
function register_error_hint(@nospecialize(handler), @nospecialize(exct::Type))
list = get!(Vector{Any}, _hint_handlers, nameof(exct))
push!(list, handler)
return nothing
end
const _hint_handlers = IdDict{Symbol,Vector{Any}}()
"""
Experimental.show_error_hints(io, ex, args...)
Invoke all handlers... | ```suggestion
hinters = get(_hint_handlers, typename(ex_supertype), nothing)
``` | """
function register_error_hint(@nospecialize(handler), @nospecialize(exct::Type))
list = get!(Vector{Any}, _hint_handlers, Core.typename(exct))
push!(list, (exct, handler))
return nothing
end
const _hint_handlers = IdDict{Core.TypeName,Vector{Any}}()
"""
Experimental.show_error_hints(io, ex, args...... | @@ -316,15 +316,20 @@ the handler for that type.
"""
function show_error_hints(io, ex, args...)
@nospecialize
- hinters = get(_hint_handlers, typeof(ex), nothing)
- isnothing(hinters) && return
- for handler in hinters
- try
- @invokelatest handler(io, ex, args...)
- catch
- ... | base/experimental.jl | 26 | Julia | 0.714 | suggestion | 90 | 51 | 51 | false | fix: trigger error hints on exception supertypes too | 59,843 | JuliaLang/julia | 35,573 | Julia | vtjnash | gdalle | Review this pull request change.
Language: Julia
File: base/experimental.jl
PR Title: fix: trigger error hints on exception supertypes too
BEFORE CODE: """
function register_error_hint(@nospecialize(handler), @nospecialize(exct::Type))
list = get!(Vector{Any}, _hint_handlers, nameof(exct))
push!(list, handl... | ```suggestion
hinters = get(_hint_handlers, typename(ex_supertype), nothing)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
end
end
```
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia> Hinter.only_int(1.0)
ERROR: MethodError: no method matching only_int(::Float64)
The function `only_int` exists, but no method is defined for this combinat... | ```suggestion
push!(list, exct, handler)
``` | end
end
```
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia> Hinter.only_int(1.0)
ERROR: MethodError: no method matching only_int(::Float64)
The function `only_int` exists, but no method is defined for this combinat... | @@ -295,18 +295,18 @@ Closest candidates are:
`if isdefined(Base.Experimental, :register_error_hint) ... end` block.
"""
function register_error_hint(@nospecialize(handler), @nospecialize(exct::Type))
- list = get!(Vector{Any}, _hint_handlers, exct)
+ list = get!(Vector{Any}, _hint_handlers, nameof(exct))
... | base/experimental.jl | 26 | Julia | 0.714 | suggestion | 50 | 51 | 51 | false | fix: trigger error hints on exception supertypes too | 59,843 | JuliaLang/julia | 35,573 | Julia | vtjnash | gdalle | Review this pull request change.
Language: Julia
File: base/experimental.jl
PR Title: fix: trigger error hints on exception supertypes too
BEFORE CODE: end
end
```
Then if you call `Hinter.only_int` on something that isn't an `Int` (thereby triggering a `MethodError`), it issues the hint:
```
julia... | ```suggestion
push!(list, exct, handler)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
list = get!(Vector{Any}, _hint_handlers, nameof(exct))
push!(list, handler)
return nothing
end
const _hint_handlers = IdDict{Symbol,Vector{Any}}()
"""
Experimental.show_error_hints(io, ex, args...)
Invoke all handlers from [`Experimental.register_error_hint`](@ref) for the particular
exception type `... | ```suggestion
for handler in 1:2:length(hinters)
ex isa hinters[handler] || continue
handler = hinters[handler + 1]
``` | list = get!(Vector{Any}, _hint_handlers, Core.typename(exct))
push!(list, (exct, handler))
return nothing
end
const _hint_handlers = IdDict{Core.TypeName,Vector{Any}}()
"""
Experimental.show_error_hints(io, ex, args...)
Invoke all handlers from [`Experimental.register_error_hint`](@ref) for the parti... | @@ -316,15 +316,20 @@ the handler for that type.
"""
function show_error_hints(io, ex, args...)
@nospecialize
- hinters = get(_hint_handlers, typeof(ex), nothing)
- isnothing(hinters) && return
- for handler in hinters
- try
- @invokelatest handler(io, ex, args...)
- catch
- ... | base/experimental.jl | 26 | Julia | 0.857 | suggestion | 155 | 51 | 51 | false | fix: trigger error hints on exception supertypes too | 59,843 | JuliaLang/julia | 35,573 | Julia | vtjnash | gdalle | Review this pull request change.
Language: Julia
File: base/experimental.jl
PR Title: fix: trigger error hints on exception supertypes too
BEFORE CODE: list = get!(Vector{Any}, _hint_handlers, nameof(exct))
push!(list, handler)
return nothing
end
const _hint_handlers = IdDict{Symbol,Vector{Any}}()
"""... | ```suggestion
for handler in 1:2:length(hinters)
ex isa hinters[handler] || continue
handler = hinters[handler + 1]
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
cache.env_project_file[env] = project_file
end
return project_file
end
end
function base_project(project_file)
home_dir = abspath(homedir())
project_dir = abspath(dirname(project_file))
current_dir = project_dir
debug = get(ENV, "JULIA_DEBUG_LOADING_WORKSPACE", nothing) == "1"
... | Is it necessary to have this exception in the algorithm? Is it to save on a couple calls to `env_project_file()` for e.g. `/home` and `/` ? | cache.env_project_file[env] = project_file
end
return project_file
end
end
function base_project(project_file)
home_dir = abspath(homedir())
project_dir = abspath(dirname(project_file))
current_dir = project_dir
# Only stop at home boundary if we started under home
started_in_ho... | @@ -671,20 +671,59 @@ function env_project_file(env::String)::Union{Bool,String}
end
function base_project(project_file)
- base_dir = abspath(joinpath(dirname(project_file), ".."))
- base_project_file = env_project_file(base_dir)
- base_project_file isa String || return nothing
- d = parsed_toml(base_pr... | base/loading.jl | 26 | Julia | 0.643 | question | 139 | 51 | 51 | false | allow specifying projects in a workspace more than one level under it | 59,849 | JuliaLang/julia | 35,573 | Julia | rfourquet | KristofferC | Review this pull request change.
Language: Julia
File: base/loading.jl
PR Title: allow specifying projects in a workspace more than one level under it
BEFORE CODE: cache.env_project_file[env] = project_file
end
return project_file
end
end
function base_project(project_file)
home_dir = abspa... | Is it necessary to have this exception in the algorithm? Is it to save on a couple calls to `env_project_file()` for e.g. `/home` and `/` ? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if isdir(env)
project_file = locate_project_file(env)
elseif basename(env) in project_names && isfile_casesensitive(env)
project_file = env
else
project_file = false
end
if cache !== nothing
cache.env_project_file[env] = project_file
end
return project_file
... | `abspath joinpath ..` is not a string operation, and will not terminate this loop correctly. you must use dirname | if isdir(env)
project_file = locate_project_file(env)
elseif basename(env) in project_names && isfile_casesensitive(env)
project_file = env
else
project_file = false
end
if cache !== nothing
cache.env_project_file[env] = project_file
end
return project_file
... | @@ -671,20 +671,59 @@ function env_project_file(env::String)::Union{Bool,String}
end
function base_project(project_file)
- base_dir = abspath(joinpath(dirname(project_file), ".."))
- base_project_file = env_project_file(base_dir)
- base_project_file isa String || return nothing
- d = parsed_toml(base_pr... | base/loading.jl | 26 | Julia | 0.571 | suggestion | 113 | 51 | 51 | false | allow specifying projects in a workspace more than one level under it | 59,849 | JuliaLang/julia | 35,573 | Julia | vtjnash | KristofferC | Review this pull request change.
Language: Julia
File: base/loading.jl
PR Title: allow specifying projects in a workspace more than one level under it
BEFORE CODE: if isdir(env)
project_file = locate_project_file(env)
elseif basename(env) in project_names && isfile_casesensitive(env)
project... | `abspath joinpath ..` is not a string operation, and will not terminate this loop correctly. you must use dirname | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
found_where = false
found_name = false
for (dep_name, entries) in d
entries::Vector{Any}
for entry in entries
entry = entry::Dict{String, Any}
uuid = get(entry, "uuid", nothing)::Union{String, Nothing}
uuid === nothing && continue
# deps is eit... | Personally, I like dealing with cases like this inline instead of having a full method definition for it. | # returns a deps list for both old and new manifest formats
function get_deps(raw_manifest::Dict)
if is_v1_format_manifest(raw_manifest)
return raw_manifest
else
# if the manifest has no deps, there won't be a `deps` field
return get(Dict{String, Any}, raw_manifest, "deps")::Dict{String,... | @@ -964,14 +980,27 @@ function get_deps(raw_manifest::Dict)
end
end
-# find `where` stanza and return the PkgId for `name`
-# return `nothing` if it did not find `where` (indicating caller should continue searching)
+function dep_stanza_get(stanza::Dict{String, Any}, name::String)::Union{Nothing, PkgId}
+ fo... | base/loading.jl | 26 | Julia | 0.429 | suggestion | 105 | 51 | 51 | false | loading: Try to clean up extension loading a bit | 59,863 | JuliaLang/julia | 35,573 | Julia | KristofferC | Keno | Review this pull request change.
Language: Julia
File: base/loading.jl
PR Title: loading: Try to clean up extension loading a bit
BEFORE CODE: found_where = false
found_name = false
for (dep_name, entries) in d
entries::Vector{Any}
for entry in entries
entry = entry::Dict{Str... | Personally, I like dealing with cases like this inline instead of having a full method definition for it. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
last_docstr = each
end
end
dict = :($(Dict{Symbol,Any})($([(:($(P)($(quot(f)), $d)))::Expr for (f, d) in fields]...)))
push!(args, :($(Pair)(:fields, $dict)))
end
return :($(Dict{Symbol,Any})($(args...)))
end
function keyworddoc(__source__, __module__, str, d... | Do we also want the value of `global x = 1`? | for each in (expr.args[3]::Expr).args
eachex = unescape(each)
if isa(eachex, Symbol) || isexpr(eachex, :(::))
# a field declaration
if last_docstr !== nothing
push!(fields, P(namify(eachex), last_docstr))
last_docstr... | @@ -383,8 +383,22 @@ function objectdoc(__source__, __module__, str, def, expr, sig = :(Union{}))
@nospecialize str def expr sig
binding = esc(bindingexpr(namify(expr)))
docstr = esc(docexpr(__source__, __module__, lazy_iterpolate(str), metadata(__source__, __module__, expr, false)))
- # Note: we wan... | base/docs/Docs.jl | 26 | Julia | 0.214 | question | 44 | 51 | 51 | false | Docs: Make `@doc` macro return the value of documented expression | 59,882 | JuliaLang/julia | 35,573 | Julia | mlechu | vtjnash | Review this pull request change.
Language: Julia
File: base/docs/Docs.jl
PR Title: Docs: Make `@doc` macro return the value of documented expression
BEFORE CODE: last_docstr = each
end
end
dict = :($(Dict{Symbol,Any})($([(:($(P)($(quot(f)), $d)))::Expr for (f, d) in field... | Do we also want the value of `global x = 1`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
size::UInt32
nfields::UInt32
npointers::UInt32
firstptr::Int32
alignment::UInt16
flags::UInt16
# haspadding : 1;
# fielddesc_type : 2;
# arrayelem_isboxed : 1;
# arrayelem_isunion : 1;
# arrayelem_isatomic : 1;
# arrayelem_islocked : 1;
# isbitsegal : 1;
# padding... | ```suggestion
layout = dt.layout::Ptr{Cvoid}
``` | size::UInt32
nfields::UInt32
npointers::UInt32
firstptr::Int32
alignment::UInt16
flags::UInt16
# haspadding : 1;
# fielddesc_type : 2;
# arrayelem_isboxed : 1;
# arrayelem_isunion : 1;
# arrayelem_isatomic : 1;
# arrayelem_islocked : 1;
# isbitsegal : 1;
# padding... | @@ -580,8 +580,9 @@ alignment of the elements, not the whole object.
"""
function datatype_alignment(dt::DataType)
@_foldable_meta
- dt.layout == C_NULL && throw(UndefRefError())
- alignment = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment
+ layout::Ptr{Cvoid} = dt.layout | base/runtime_internals.jl | 26 | Julia | 0.571 | suggestion | 54 | 51 | 51 | false | Type-assert `DataType.layout` in some Base functions | 59,886 | JuliaLang/julia | 35,573 | Julia | aviatesk | JamesWrigley | Review this pull request change.
Language: Julia
File: base/runtime_internals.jl
PR Title: Type-assert `DataType.layout` in some Base functions
BEFORE CODE: size::UInt32
nfields::UInt32
npointers::UInt32
firstptr::Int32
alignment::UInt16
flags::UInt16
# haspadding : 1;
# fielddesc_ty... | ```suggestion
layout = dt.layout::Ptr{Cvoid}
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
dt.layout == C_NULL && throw(UndefRefError())
flags = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).flags
return (flags & (1<<7)) != 0
end
"""
Base.datatype_nfields(dt::DataType)::UInt32
Return the number of fields known to this datatype's layout. This may be
different from the number of actual... | ```suggestion
layout = dt.layout::Ptr{Cvoid}
```
Wouldn't type assertion without unnecessary `convert` be better? | dt.layout == C_NULL && throw(UndefRefError())
flags = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).flags
return (flags & (1<<7)) != 0
end
"""
Base.datatype_nfields(dt::DataType)::UInt32
Return the number of fields known to this datatype's layout. This may be
different from the number of actual... | @@ -664,8 +665,9 @@ Return the number of pointers in the layout of a datatype.
"""
function datatype_npointers(dt::DataType)
@_foldable_meta
- dt.layout == C_NULL && throw(UndefRefError())
- return unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).npointers
+ layout::Ptr{Cvoid} = dt.layout | base/runtime_internals.jl | 26 | Julia | 0.929 | question | 120 | 51 | 51 | false | Type-assert `DataType.layout` in some Base functions | 59,886 | JuliaLang/julia | 35,573 | Julia | aviatesk | JamesWrigley | Review this pull request change.
Language: Julia
File: base/runtime_internals.jl
PR Title: Type-assert `DataType.layout` in some Base functions
BEFORE CODE: dt.layout == C_NULL && throw(UndefRefError())
flags = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).flags
return (flags & (1<<7)) != 0
end
... | ```suggestion
layout = dt.layout::Ptr{Cvoid}
```
Wouldn't type assertion without unnecessary `convert` be better? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# with failfast=false
for t in tasks
_wait(t)
exception |= istaskfailed(t)
end
if exception && throwexc
exceptions = [TaskFailedException(t) for t in tasks if istaskfailed(t)]
throw(CompositeException(exceptions))
else
r... | Is the throwing & failfast combination tested? | # with failfast=false
for t in tasks
_wait(t)
exception |= istaskfailed(t)
end
if exception && throwexc
exceptions = [TaskFailedException(t) for t in tasks if istaskfailed(t)]
throw(CompositeException(exceptions))
else
r... | @@ -435,19 +435,21 @@ function _wait_multiple(waiting_tasks, throwexc=false, all=false, failfast=false
done_mask[i] = true
exception |= istaskfailed(t)
nremaining -= 1
- else
- done_mask[i] = false
end
end
- if nremaining == 0
- return t... | base/task.jl | 26 | Julia | 0.071 | bug | 46 | 51 | 51 | false | Fix: waitall can throw when all tasks are done | 59,905 | JuliaLang/julia | 35,573 | Julia | Seelengrab | jakobnissen | Review this pull request change.
Language: Julia
File: base/task.jl
PR Title: Fix: waitall can throw when all tasks are done
BEFORE CODE: # with failfast=false
for t in tasks
_wait(t)
exception |= istaskfailed(t)
end
if exception && throwexc
except... | Is the throwing & failfast combination tested? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
static int thread0_exit_count = 0;
static void jl_exit_thread0(int signo, jl_bt_element_t *bt_data, size_t bt_size);
int jl_simulate_longjmp(jl_jmp_buf mctx, bt_context_t *c) JL_NOTSAFEPOINT;
static void jl_longjmp_in_ctx(int sig, void *_ctx, jl_jmp_buf jmpbuf);
// create a fake function that describes the variable m... | ```suggestion
#elif defined(_OS_DARWIN_) && defined(_CPU_AARCH64_)
```
GCC implements this function wrong (crashes the compiler) | static int thread0_exit_count = 0;
static void jl_exit_thread0(int signo, jl_bt_element_t *bt_data, size_t bt_size);
int jl_simulate_longjmp(jl_jmp_buf mctx, bt_context_t *c) JL_NOTSAFEPOINT;
static void jl_longjmp_in_ctx(int sig, void *_ctx, jl_jmp_buf jmpbuf);
#if !defined(_OS_DARWIN_)
extern void jl_fake_signal_re... | @@ -69,6 +69,43 @@ static void jl_exit_thread0(int signo, jl_bt_element_t *bt_data, size_t bt_size)
int jl_simulate_longjmp(jl_jmp_buf mctx, bt_context_t *c) JL_NOTSAFEPOINT;
static void jl_longjmp_in_ctx(int sig, void *_ctx, jl_jmp_buf jmpbuf);
+// create a fake function that describes the variable manipulations i... | src/signals-unix.c | 26 | C | 0.714 | bug | 133 | 51 | 51 | false | signals: Implement fake_stack_pop for Linux on x86_64 and i686 | 60,013 | JuliaLang/julia | 35,573 | Julia | vtjnash | vtjnash | Review this pull request change.
Language: C
File: src/signals-unix.c
PR Title: signals: Implement fake_stack_pop for Linux on x86_64 and i686
BEFORE CODE: static int thread0_exit_count = 0;
static void jl_exit_thread0(int signo, jl_bt_element_t *bt_data, size_t bt_size);
int jl_simulate_longjmp(jl_jmp_buf mctx, b... | ```suggestion
#elif defined(_OS_DARWIN_) && defined(_CPU_AARCH64_)
```
GCC implements this function wrong (crashes the compiler) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
origin="origin/"
fi
git_time=$(git log -1 --pretty=format:%ct)
#collect the contents
commit=$(git rev-parse HEAD)
commit_short=$(git rev-parse --short HEAD)
if [ -n "$(git status --porcelain)" ]; then
# append dirty mark '*' if the repository has uncommitted changes
commit_short="$commit_short"*
fi
# Our ... | Could we instead change this to `git status --porcelain ${COMPILER_SRCS} ${BASE_SRCS} ${STDLIB_SRCS}` (these variables are defined during sysimage.mk), which seems like it should have the equivalent effect, but without the awkward build stickiness of this current implementation just failing to track a particular change... | echo " else"
echo " return getfield(info, s)"
echo " end"
echo "end"
echo ""
cd $1
# If the script didn't ask not to use git info
if [ "$#" = "2" -a "$2" = "NO_GIT" ]; then
# this comment is used in base/Makefile to distinguish boilerplate
echo "# Default output if git is not available."
ec... | @@ -38,8 +56,9 @@ git_time=$(git log -1 --pretty=format:%ct)
commit=$(git rev-parse HEAD)
commit_short=$(git rev-parse --short HEAD)
if [ -n "$(git status --porcelain)" ]; then | base/version_git.sh | 26 | Shell | 0.643 | bug | 442 | 51 | 51 | false | Don't trigger full rebuild if git is dirty | 60,023 | JuliaLang/julia | 35,573 | Julia | vtjnash | IanButterworth | Review this pull request change.
Language: Shell
File: base/version_git.sh
PR Title: Don't trigger full rebuild if git is dirty
BEFORE CODE: origin="origin/"
fi
git_time=$(git log -1 --pretty=format:%ct)
#collect the contents
commit=$(git rev-parse HEAD)
commit_short=$(git rev-parse --short HEAD)
if [ -n "$(gi... | Could we instead change this to `git status --porcelain ${COMPILER_SRCS} ${BASE_SRCS} ${STDLIB_SRCS}` (these variables are defined during sysimage.mk), which seems like it should have the equivalent effect, but without the awkward build stickiness of this current implementation just failing to track a particular change... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
GitReference(repo, obj_oid, force=force,
msg="libgit2.checkout: moving from $head_name to $(obj_oid))")
return nothing
end
"""
clone(repo_url::AbstractString, repo_path::AbstractString; kwargs...)
Clone a remote repository located at `repo_url` to the local filesystem location `repo_pat... | Add a link to the upstream bug for this as a reference so people in the future can re-check whether this is still true? https://github.com/libgit2/libgit2/issues/6634 | checkout_tree(repo, peeled, options = force ? CheckoutOptions(checkout_strategy = Consts.CHECKOUT_FORCE) : CheckoutOptions())
GitReference(repo, obj_oid, force=force,
msg="libgit2.checkout: moving from $head_name to $(obj_oid))")
return nothing
end
"""
clone(repo_url::AbstractString,... | @@ -539,11 +549,15 @@ The keyword arguments are:
* `remote_cb::Ptr{Cvoid}=C_NULL`: a callback which will be used to create the remote
before it is cloned. If `C_NULL` (the default), no attempt will be made to create
the remote - it will be assumed to already exist.
+ * `depth::Integer=0`: create a shallow... | stdlib/LibGit2/src/LibGit2.jl | 26 | Julia | 0.5 | bug | 166 | 51 | 51 | false | LibGit2: expose the depth option to clone and fetch | 60,024 | JuliaLang/julia | 35,573 | Julia | Keno | KristofferC | Review this pull request change.
Language: Julia
File: stdlib/LibGit2/src/LibGit2.jl
PR Title: LibGit2: expose the depth option to clone and fetch
BEFORE CODE:
GitReference(repo, obj_oid, force=force,
msg="libgit2.checkout: moving from $head_name to $(obj_oid))")
return nothing
end
"""
... | Add a link to the upstream bug for this as a reference so people in the future can re-check whether this is still true? https://github.com/libgit2/libgit2/issues/6634 | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if isempty(common_name)
@warn "Skipping hostname verification tests. Unable to determine a hostname which maps to the loopback address"
end
end
if openssl_installed && !isempty(common_name)
mktempdir() do root
key = joinpath(root, commo... | This relies on system openssl executable, no? | if isempty(common_name)
@warn "Skipping hostname verification tests. Unable to determine a hostname which maps to the loopback address"
end
end
if openssl_installed && !isempty(common_name)
mktempdir() do root
key = joinpath(root, commo... | @@ -3093,9 +3093,15 @@ mktempdir() do dir
key = joinpath(root, common_name * ".key")
cert = joinpath(root, common_name * ".crt")
pem = joinpath(root, common_name * ".pem")
+ conf = joinpath(root, common_name * ".conf")
+
+ # Make sure test... | stdlib/LibGit2/test/libgit2-tests.jl | 26 | Julia | 0.071 | question | 45 | 51 | 51 | false | libgit2/test: Handle a partially broken openssl install | 60,035 | JuliaLang/julia | 35,573 | Julia | giordano | Keno | Review this pull request change.
Language: Julia
File: stdlib/LibGit2/test/libgit2-tests.jl
PR Title: libgit2/test: Handle a partially broken openssl install
BEFORE CODE: if isempty(common_name)
@warn "Skipping hostname verification tests. Unable to determine a hostname which maps to the... | This relies on system openssl executable, no? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if foreigncall isa QuoteNode
if foreigncall.value in runtime_functions
error = "disallowed ccall into a runtime function"
end
else
error = "disallowed ccall with non-constant name and no library"
... | This makes things less parallel structured here (normally the function sets the error message, then uses continue to skip it, instead of attempting to catch every possible else clause) | end
function verify_codeinstance!(interp::NativeInterpreter, codeinst::CodeInstance, codeinfo::CodeInfo, inspected::IdSet{CodeInstance}, caches::IdDict{MethodInstance,CodeInstance}, parents::ParentMap, errors::ErrorList)
mi = get_ci_mi(codeinst)
sptypes = sptypes_from_meth_instance(mi)
src = codeinfo.code
... | @@ -189,7 +189,6 @@ function verify_codeinstance!(interp::NativeInterpreter, codeinst::CodeInstance,
end
# TODO: check for calls to Base.atexit?
elseif isexpr(stmt, :call)
- error = "unresolved call" | Compiler/src/verifytrim.jl | 26 | Julia | 0.571 | suggestion | 184 | 51 | 51 | false | trimming: fix-up support for `Core._apply_iterate` | 60,062 | JuliaLang/julia | 35,573 | Julia | vtjnash | topolarity | Review this pull request change.
Language: Julia
File: Compiler/src/verifytrim.jl
PR Title: trimming: fix-up support for `Core._apply_iterate`
BEFORE CODE: if foreigncall isa QuoteNode
if foreigncall.value in runtime_functions
error = "disallowed ccall int... | This makes things less parallel structured here (normally the function sets the error message, then uses continue to skip it, instead of attempting to catch every possible else clause) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
isexpr(@nospecialize(ex), heads) = isa(ex, Expr) && in(ex.head, heads)
isexpr(@nospecialize(ex), heads, n::Int) = isa(ex, Expr) && in(ex.head, heads) && length(ex.args) == n
const is_expr = isexpr
## symbols ##
"""
gensym([tag])
Gener... | Note that it is definitely not unique among names in the process (as the failed tests show), but only from context of defining one module | # This file is a part of Julia. License is MIT: https://julialang.org/license
isexpr(@nospecialize(ex), heads) = isa(ex, Expr) && in(ex.head, heads)
isexpr(@nospecialize(ex), heads, n::Int) = isa(ex, Expr) && in(ex.head, heads) && length(ex.args) == n
const is_expr = isexpr
## symbols ##
"""
gensym([tag])
Gener... | @@ -9,7 +9,8 @@ const is_expr = isexpr
"""
gensym([tag])
-Generates a symbol which will not conflict with other variable names (in the same module).
+Generate a symbol unique among all calls to this function within the same process. | base/expr.jl | 12 | Julia | 0.357 | bug | 137 | 37 | 37 | false | correct docstring for `gensym` | 60,064 | JuliaLang/julia | 35,573 | Julia | vtjnash | JeffBezanson | Review this pull request change.
Language: Julia
File: base/expr.jl
PR Title: correct docstring for `gensym`
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
isexpr(@nospecialize(ex), heads) = isa(ex, Expr) && in(ex.head, heads)
isexpr(@nospecialize(ex), heads, n::Int) = i... | Note that it is definitely not unique among names in the process (as the failed tests show), but only from context of defining one module | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
freecall ::Int64
total_time ::Int64
total_allocd ::Int64 # GC internal
collect ::Csize_t # GC internal
pause ::Cint
full_sweep ::Cint
max_pause ::Int64
max_memory ::Int64
time_to_safepoint ::Int64
max_time_to_safepoint ... | Apart from this change, LGTM. Will a nanosoldier run show how much breakage this will cause? | deferred_alloc::Int64
# (GC Internal) Number of bytes freed bytes in the current collection cycle. This field is
# reset after every garbage collection cycle and will always be zero when observed
# during execution of Julia user code. It's incremented as memory is reclaimed during a collection,
# us... | @@ -2,35 +2,76 @@
# This type must be kept in sync with the C struct in src/gc-interface.h
struct GC_Num
- allocd ::Int64 # GC internal
- deferred_alloc ::Int64 # GC internal
- freed ::Int64 # GC internal
- malloc ::Int64
- realloc ::Int64
- poolalloc ::I... | base/timing.jl | 26 | Julia | 0.286 | question | 92 | 51 | 51 | false | document metrics from GC_Num; rename one metric from GC_Num to match the name used by the equivalent C struct | 60,115 | JuliaLang/julia | 35,573 | Julia | kpamnany | d-netto | Review this pull request change.
Language: Julia
File: base/timing.jl
PR Title: document metrics from GC_Num; rename one metric from GC_Num to match the name used by the equivalent C struct
BEFORE CODE: freecall ::Int64
total_time ::Int64
total_allocd ::Int64 # GC internal
collect ... | Apart from this change, LGTM. Will a nanosoldier run show how much breakage this will cause? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
11//25 + 2//25*im
julia> 1.0 // 2
ERROR: MethodError: no method matching //(::Float64, ::Int64)
[...]
```
"""
//(n::Integer, d::Integer) = Rational(n,d)
function //(x::Rational, y::Integer)
xn, yn = divgcd(promote(x.num, y)...)
checked_den(xn, checked_mul(x.den, yn))
end
function //(x::Integer, y::Rational)... | rather than adding a comment I would either deprecate this in a separate PR or track the TODO in a separate issue | 11//25 + 2//25*im
julia> 1.0 // 2
ERROR: MethodError: no method matching //(::Float64, ::Int64)
[...]
```
"""
//(n::Integer, d::Integer) = Rational(n,d)
function //(x::Rational, y::Integer)
xn, yn = divgcd(promote(x.num, y)...)
checked_den(xn, checked_mul(x.den, yn))
end
function //(x::Integer, y::Rational)... | @@ -105,8 +105,28 @@ function //(x::Rational, y::Rational)
end
//(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
+
+# TODO Unclear if this method should be defined. It seems to conflict with the docstring that states that "The arguments must be subtypes of Integer, Rational, or composites thereof." | base/rational.jl | 26 | Julia | 0.357 | suggestion | 113 | 51 | 51 | false | Fix overflow in complex // | 60,130 | JuliaLang/julia | 35,573 | Julia | adienes | nhz2 | Review this pull request change.
Language: Julia
File: base/rational.jl
PR Title: Fix overflow in complex //
BEFORE CODE: 11//25 + 2//25*im
julia> 1.0 // 2
ERROR: MethodError: no method matching //(::Float64, ::Int64)
[...]
```
"""
//(n::Integer, d::Integer) = Rational(n,d)
function //(x::Rational, y::Integer)
... | rather than adding a comment I would either deprecate this in a separate PR or track the TODO in a separate issue | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
//(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
function //(x::Number, y::Complex{<:Rational})
c, d = reim(y)
if (isinf(c) | isinf(d))
x * conj(zero(y))
else
x * conj(y)
end//abs2(y)
end
function //(x::Number, y::Complex{<:Integer})
c, d = reim(y)
c_r, d_r = divgcd(c, d... | is there any meaningful performance difference to spelling this method all out vs forwarding?
```
//(x::Integer, y::Complex{<:Integer}) = complex(x) // y
``` | //(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
# Return a complex numerator and real denominator
# of the exact inverse of a Complex number.
function _complex_exact_inv(y::Complex)
c, d = reim(y)
num = if (isinf(c) | isinf(d))
conj(zero(y))
else
conj(y)
end
num, abs2(y)
e... | @@ -105,8 +105,35 @@ function //(x::Rational, y::Rational)
end
//(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
-//(x::Number, y::Complex) = x*conj(y)//abs2(y)
-
+function //(x::Number, y::Complex{<:Rational})
+ c, d = reim(y)
+ if (isinf(c) | isinf(d))
+ x * conj(zero(y))
+ else
+ x... | base/rational.jl | 26 | Julia | 0.857 | performance | 160 | 51 | 51 | false | Fix overflow in complex // | 60,130 | JuliaLang/julia | 35,573 | Julia | adienes | nhz2 | Review this pull request change.
Language: Julia
File: base/rational.jl
PR Title: Fix overflow in complex //
BEFORE CODE: //(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
function //(x::Number, y::Complex{<:Rational})
c, d = reim(y)
if (isinf(c) | isinf(d))
x * conj(zero(y))
else
... | is there any meaningful performance difference to spelling this method all out vs forwarding?
```
//(x::Integer, y::Complex{<:Integer}) = complex(x) // y
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
```
"""
//(n::Integer, d::Integer) = Rational(n,d)
function //(x::Rational, y::Integer)
xn, yn = divgcd(promote(x.num, y)...)
checked_den(xn, checked_mul(x.den, yn))
end
function //(x::Integer, y::Rational)
xn, yn = divgcd(promote(x, y.num)...)
checked_den(checked_mul(xn, y.den), yn)
end
function //(... | ```suggestion
```
don't intend to be style police but something about this looks so unsettling haha | ```
"""
//(n::Integer, d::Integer) = Rational(n,d)
function //(x::Rational, y::Integer)
xn, yn = divgcd(promote(x.num, y)...)
checked_den(xn, checked_mul(x.den, yn))
end
function //(x::Integer, y::Rational)
xn, yn = divgcd(promote(x, y.num)...)
checked_den(checked_mul(xn, y.den), yn)
end
function //(... | @@ -105,8 +105,32 @@ function //(x::Rational, y::Rational)
end
//(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
-//(x::Number, y::Complex) = x*conj(y)//abs2(y)
-
+function //(x::Number, y::Complex{<:Rational})
+ c, d = reim(y)
+ if (isinf(c) | isinf(d))
+ x * conj(zero(y))
+ else
+ x... | base/rational.jl | 26 | Julia | 0.714 | suggestion | 105 | 51 | 51 | false | Fix overflow in complex // | 60,130 | JuliaLang/julia | 35,573 | Julia | adienes | nhz2 | Review this pull request change.
Language: Julia
File: base/rational.jl
PR Title: Fix overflow in complex //
BEFORE CODE: ```
"""
//(n::Integer, d::Integer) = Rational(n,d)
function //(x::Rational, y::Integer)
xn, yn = divgcd(promote(x.num, y)...)
checked_den(xn, checked_mul(x.den, yn))
end
function //(x:... | ```suggestion
```
don't intend to be style police but something about this looks so unsettling haha | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
name_val=String, is_toplevel_thunk=Bool,
scope_layer=LayerId, meta=CompileHints,
toplevel_pure=Bool)
expr_to_syntaxtree(graph, e, lnn)
end
@fzone "JL: expr_to_syntaxtree" function expr_to_syntaxtree(ctx, @nospecialize(e), lnn::Union{LineNumberNode, Nothing})
graph = syntax_graph(ctx)
... | ```suggestion
Expr(e.head, Any[_expr_replace(a, replace_pred, replacer, recurse_pred) for a in e.args]...)
``` | name_val=String, is_toplevel_thunk=Bool,
scope_layer=LayerId, meta=CompileHints,
toplevel_pure=Bool)
expr_to_syntaxtree(graph, e, lnn)
end
@fzone "JL: expr_to_syntaxtree" function expr_to_syntaxtree(ctx, @nospecialize(e), lnn::Union{LineNumberNode, Nothing})
graph = syntax_graph(ctx)
... | @@ -46,18 +44,24 @@ end
return out
end
-function _expr_replace!(@nospecialize(e), replace_pred::Function, replacer!::Function,
+function _expr_replace(@nospecialize(e), replace_pred::Function, replacer::Function,
recurse_pred=(@nospecialize e)->true)
if replace_pred(e)
- rep... | JuliaLowering/src/compat.jl | 26 | Julia | 0.786 | suggestion | 120 | 51 | 51 | false | Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug | 60,162 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/compat.jl
PR Title: Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug
BEFORE CODE: name_val=String, is_toplevel_thunk=Bool,
scope_layer=LayerId, meta=CompileHints,
toplevel_pure=Bool)
expr_to_syntaxtree(graph, e, l... | ```suggestion
Expr(e.head, Any[_expr_replace(a, replace_pred, replacer, recurse_pred) for a in e.args]...)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# extensions":
#
# * They emit syntactic forms with special `Kind`s and semantics known to
# lowering
# * There is no other Julia surface syntax for these `Kind`s.
# In order to implement these here without getting into bootstrapping problems,
# we just write them as plain old macro-named functions and add the requi... | ```suggestion
elseif k == K"=" && numchildren(ex) == 2
``` | # extensions":
#
# * They emit syntactic forms with special `Kind`s and semantics known to
# lowering
# * There is no other Julia surface syntax for these `Kind`s.
# In order to implement these here without getting into bootstrapping problems,
# we just write them as plain old macro-named functions and add the requi... | @@ -19,9 +19,13 @@ function _apply_nospecialize(ctx, ex)
k = kind(ex)
if k == K"Identifier" || k == K"Placeholder" || k == K"tuple"
setmeta(ex; nospecialize=true)
- elseif k == K"..." || k == K"::" || k == K"="
+ elseif k == K"..." || k == K"::" || k == K"=" || k == K"kw"
+ # The @nospec... | JuliaLowering/src/syntax_macros.jl | 26 | Julia | 0.571 | suggestion | 68 | 51 | 51 | false | Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug | 60,162 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/syntax_macros.jl
PR Title: Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug
BEFORE CODE: # extensions":
#
# * They emit syntactic forms with special `Kind`s and semantics known to
# lowering
# * There is no other Julia surface syntax for t... | ```suggestion
elseif k == K"=" && numchildren(ex) == 2
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return Expr(:filter, _to_iterspec(exs[1].args[2:end], true), exs[1].args[1])
end
outex = Expr(:iteration)
for e in exs
if e.head === :block && !is_generator
for iter in e.args
push!(outex.args, Expr(:in, iter.args...))
end
elseif e.head === :(=... | Conceptually this is:
```julia
map!(collect_expr_parameters(e, pos)) do arg
Meta.isexpr(arg, :parameters) ? _eq_to_kw(arg) : arg
end
```
is that right?
If so, may be clearer just to transform after the fact, since 1 / 3 usages already needs a fix-up anyway | end
elseif e.head === :(=)
push!(outex.args, Expr(:in, e.args...))
else
@assert false "unknown iterspec in $e"
end
end
return outex
end
"""
Return `e.args`, but with any parameters in SyntaxTree (flattened, source) order.
Parameters are expected to be... | @@ -85,19 +89,25 @@ Parameters are expected to be at `e.args[pos]`.
e.g. orderings of (a,b,c;d;e;f):
Expr: (tuple (parameters (parameters (parameters f) e) d) a b c)
SyntaxTree: (tuple a b c (parameters d) (parameters e) (parameters f))
+
+`ensure_kw` converts `=` to `kw` within parameters blocks (needed f... | JuliaLowering/src/compat.jl | 26 | Julia | 0.786 | suggestion | 269 | 51 | 51 | false | Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug | 60,162 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/compat.jl
PR Title: Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug
BEFORE CODE: return Expr(:filter, _to_iterspec(exs[1].args[2:end], true), exs[1].args[1])
end
outex = Expr(:iteration)
for e in exs
if e.head ==... | Conceptually this is:
```julia
map!(collect_expr_parameters(e, pos)) do arg
Meta.isexpr(arg, :parameters) ? _eq_to_kw(arg) : arg
end
```
is that right?
If so, may be clearer just to transform after the fact, since 1 / 3 usages already needs a fix-up anyway | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@assert nargs === 1
st_k = K"call"
child_exprs = Any[e.head, e.args[1]]
elseif e.head === :. && nargs === 2
a2, a2_esc = unwrap_esc(e.args[2])
if a2 isa Expr && a2.head === :tuple
st_k = K"dotcall"
tuple_exprs = collect_expr_parameters(a2_esc(a2), 1, f... | This requires a `@view`, right? | @assert nargs === 2
child_exprs = Any[_to_iterspec(Any[e.args[1]], false), e.args[2]]
elseif e.head === :where
@assert nargs >= 2
e2,_ = unwrap_esc(e.args[2])
if !(e2 isa Expr && e2.head === :braces)
child_exprs = Any[e.args[1], Expr(:braces, e.args[2:end]...)]
... | @@ -311,10 +321,16 @@ function _insert_convert_expr(@nospecialize(e), graph::SyntaxGraph, src::SourceA
if !(e2 isa Expr && e2.head === :braces)
child_exprs = Any[e.args[1], Expr(:braces, e.args[2:end]...)]
end
- elseif e.head in (:tuple, :vect, :braces)
- child_exprs = collect_e... | JuliaLowering/src/compat.jl | 26 | Julia | 0.214 | question | 31 | 51 | 51 | false | Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug | 60,162 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/compat.jl
PR Title: Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug
BEFORE CODE: @assert nargs === 1
st_k = K"call"
child_exprs = Any[e.head, e.args[1]]
elseif e.head === :. && nargs === 2
a2, a2_esc = un... | This requires a `@view`, right? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
]
]
[K"removable"
isnothing(bare_func_name) ? "nothing"::K"core" : bare_func_name
]
]
end
#-------------------------------------------------------------------------------
# Anon function syntax
function expand_arrow_arglist(ctx, arglist, arrowname)
k = kind(argli... | ```suggestion
kw = arglist[2]
if kind(kw) === K"="
kw = @ast(ctx, kw, [K"kw" children(kw)...])
end
```
just a minor suggestion, but reads more easily imo | push!(method_stmts,
method_def_expr(ctx, ex, callex, method_table, main_typevar_names, arg_names,
arg_types, body, ret_var))
if !isnothing(docs)
method_stmts[end] = @ast ctx docs [K"block"
method_metadata := method_stmts[end]
[K"call"
... | @@ -3212,9 +3214,13 @@ function expand_arrow_arglist(ctx, arglist, arrowname)
# https://github.com/JuliaLang/JuliaSyntax.jl/pull/522
if k == K"block"
@chk numchildren(arglist) == 2
+ kw = kind(arglist[2]) === K"=" ?
+ @ast(ctx, arglist[2], [K"kw" children(arglist... | JuliaLowering/src/desugaring.jl | 26 | Julia | 0.786 | suggestion | 213 | 51 | 51 | false | Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug | 60,162 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/desugaring.jl
PR Title: Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug
BEFORE CODE: ]
]
[K"removable"
isnothing(bare_func_name) ? "nothing"::K"core" : bare_func_name
]
]
end
#-----------... | ```suggestion
kw = arglist[2]
if kind(kw) === K"="
kw = @ast(ctx, kw, [K"kw" children(kw)...])
end
```
just a minor suggestion, but reads more easily imo | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
setchildren!(graph, id, reverse(cs).ids)
setattr!(graph, id; source, kind=K"wrapper")
return SyntaxTree(graph, id)
end
function SyntaxTree(graph::SyntaxGraph, sf::SourceFile, cursor::RedTreeCursor)
ensure_attributes!(graph, kind=Kind, syntax_flags=UInt16,
source=SourceAttrType, v... | Is this re-parsing the source file?
I'm confused why we do this here, esp. just for literals | green_id = GC.@preserve sf begin
raw_offset, txtbuf = _unsafe_wrap_substring(sf.code)
offset = raw_offset - sf.byte_offset
_insert_green(graph, sf, txtbuf, offset, cursor)
end
out = _green_to_ast(K"None", SyntaxTree(graph, green_id))
@assert !isnothing(out) "SyntaxTree requires >... | @@ -826,3 +818,108 @@ end
# end
# out
# end
+
+#-------------------------------------------------------------------------------
+# Conversion from the raw parsed tree
+# TODO: move to JuliaSyntax. Replace SyntaxNode?
+
+function JuliaSyntax.build_tree(::Type{SyntaxTree}, stream::ParseStream;
+ ... | JuliaLowering/src/syntax_graph.jl | 26 | Julia | 0.286 | question | 95 | 51 | 51 | false | Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug | 60,162 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/syntax_graph.jl
PR Title: Bypass `SyntaxNode` in JuliaLowering; fix `kw` bug
BEFORE CODE: setchildren!(graph, id, reverse(cs).ids)
setattr!(graph, id; source, kind=K"wrapper")
return SyntaxTree(graph, id)
end
function SyntaxTree(g... | Is this re-parsing the source file?
I'm confused why we do this here, esp. just for literals | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@test sum(x for x in v) == sum(A)
v = view(A, 1:2:lastindex(A))
@test sum(x for x in v) == sum(A[1:2:end])
v2 = view(A, Base.IdentityUnitRange(1:length(A)))
@test sum(x for x in v2) == sum(A)
end
@testset "self referential" begin
v = Any[1,2,3]
v[1] = v
io = IOBuffer()
show(io, v)
... | sometimes 1d is a special case; could you add one or two more test cases comparing 2d to 3d? (and maybe similarly some for 0d which is also often special cased) | @test sum(x for x in v) == sum(A)
v = view(A, 1:2:lastindex(A))
@test sum(x for x in v) == sum(A[1:2:end])
v2 = view(A, Base.IdentityUnitRange(1:length(A)))
@test sum(x for x in v2) == sum(A)
end
@testset "self referential" begin
v = Any[1,2,3]
v[1] = v
io = IOBuffer()
show(io, v)
... | @@ -2376,3 +2376,10 @@ end
show(io, m2)
@test String(take!(io)) == "Any[#= circular reference @-1 =# 3; 2 4;;; 5 7; 6 8]"
end
+
+@testset "size promotion in addition/subtraction" begin | test/abstractarray.jl | 26 | Julia | 0.429 | suggestion | 160 | 32 | 38 | false | Fix linearly indexed array math by reshaping arrays | 60,164 | JuliaLang/julia | 35,573 | Julia | adienes | jishnub | Review this pull request change.
Language: Julia
File: test/abstractarray.jl
PR Title: Fix linearly indexed array math by reshaping arrays
BEFORE CODE: @test sum(x for x in v) == sum(A)
v = view(A, 1:2:lastindex(A))
@test sum(x for x in v) == sum(A[1:2:end])
v2 = view(A, Base.IdentityUnitRange(1:len... | sometimes 1d is a special case; could you add one or two more test cases comparing 2d to 3d? (and maybe similarly some for 0d which is also often special cased) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return Core.svec(:done)
end
ex, is_module_body, child_idx = pop!(iter.todo)
if child_idx > 0
next_child = child_idx + 1
if child_idx <= numchildren(ex)
push!(iter.todo, (ex, is_module_body, next_child))
ex = ex[child_idx]
else
if is_module... | This might be worth a separate helper / constructor
One common pattern is:
```julia
MacroExpansionContext(ctx::MacroExpansionContext; graph = ctx.graph, bindings = ctx.bindings, scope_layers = ctx.scope_layers, scope_layer_stack = ctx.scope_layer_stack, expr_compat_mode = ctx.expr_compat_mode, world = ctx.world) =... | push!(iter.todo, (top_ex, is_module_body, child_idx + 1))
ex = top_ex[child_idx]
elseif is_module_body
return Core.svec(:end_module)
else
return lower_step(iter, mod)
end
else
ex = top_ex
end
k = kind(ex)
if !(k in KSet"top... | @@ -71,7 +71,12 @@ function lower_step(iter, push_mod=nothing)
k = kind(ex)
if !(k in KSet"toplevel module")
- ex = expand_forms_1(iter.ctx, ex)
+ ctx1 = let c = iter.ctx
+ MacroExpansionContext(
+ c.graph, c.bindings, c.scope_layers, c.scope_layer_stack,
+ ... | JuliaLowering/src/eval.jl | 26 | Julia | 0.786 | refactor | 481 | 51 | 51 | false | [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator | 60,168 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/eval.jl
PR Title: [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator
BEFORE CODE: return Core.svec(:done)
end
ex, is_module_body, child_idx = pop!(iter.todo)
if child_idx > 0
next_child = child_id... | This might be worth a separate helper / constructor
One common pattern is:
```julia
MacroExpansionContext(ctx::MacroExpansionContext; graph = ctx.graph, bindings = ctx.bindings, scope_layers = ctx.scope_layers, scope_layer_stack = ctx.scope_layer_stack, expr_compat_mode = ctx.expr_compat_mode, world = ctx.world) =... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#
# * Lowering knows when new modules are required, and may request them with
# `:begin_module`. However `eval()` generates those modules so they need to
# be passed back into lowering. So we can't just use `Base.iterate()`. (Put a
# different way, we have a situation which is suited to coroutines but we
# don'... | Why does this use `get_world_counter` instead of `tls_world_age`? | #
# * Lowering knows when new modules are required, and may request them with
# `:begin_module`. However `eval()` generates those modules so they need to
# be passed back into lowering. So we can't just use `Base.iterate()`. (Put a
# different way, we have a situation which is suited to coroutines but we
# don'... | @@ -44,7 +44,7 @@ function lower_init(ex::SyntaxTree, mod::Module, macro_world::UInt; expr_compat_
LoweringIterator{typeof(graph)}(ctx, [(ex, false, 0)])
end
-function lower_step(iter, push_mod=nothing)
+function lower_step(iter, world=Base.get_world_counter(), push_mod=nothing) | JuliaLowering/src/eval.jl | 26 | Julia | 0.429 | question | 65 | 51 | 51 | false | [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator | 60,168 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/eval.jl
PR Title: [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator
BEFORE CODE: #
# * Lowering knows when new modules are required, and may request them with
# `:begin_module`. However `eval()` generates those modules so ... | Why does this use `get_world_counter` instead of `tls_world_age`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
function macroexpand(mod::Module, ex; expr_compat_mode=false, world=Base.get_world_counter())
ctx1, ex1 = expand_forms_1(mod, ex, expr_compat_mode, world)
ex1
end
# Incremental lowering API which can manage toplevel and module expressions.
#
# This iteration API is oddly bespoke and arguably somewhat non-Julia... | `macro_world` or `initial_macro_world` might be more consistent with the name / usage in `MacroExpansionContext` | function macroexpand(mod::Module, ex; expr_compat_mode=false, world=Base.get_world_counter())
ctx1, ex1 = expand_forms_1(mod, ex, expr_compat_mode, world)
ex1
end
# Incremental lowering API which can manage toplevel and module expressions.
#
# This iteration API is oddly bespoke and arguably somewhat non-Julia... | @@ -33,50 +33,45 @@ end
# how we end up putting this into Base.
struct LoweringIterator{GraphType}
- ctx::MacroExpansionContext{GraphType}
+ # We don't currently use this iterator outside of eval (which should always
+ # use the latest world), but this is necessary for passing it in if we did
+ init_wor... | JuliaLowering/src/eval.jl | 26 | Julia | 0.5 | suggestion | 112 | 51 | 51 | false | [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator | 60,168 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/eval.jl
PR Title: [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator
BEFORE CODE: function macroexpand(mod::Module, ex; expr_compat_mode=false, world=Base.get_world_counter())
ctx1, ex1 = expand_forms_1(mod, ex, expr_comp... | `macro_world` or `initial_macro_world` might be more consistent with the name / usage in `MacroExpansionContext` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# * Lowering knows when new modules are required, and may request them with
# `:begin_module`. However `eval()` generates those modules so they need to
# be passed back into lowering. So we can't just use `Base.iterate()`. (Put a
# different way, we have a situation which is suited to coroutines but we
# don't ... | Having the `world` in both the iterator and a separate parameter is a bit unusual.
Is there a reason it needs to be in the iterator at all? | # * Lowering knows when new modules are required, and may request them with
# `:begin_module`. However `eval()` generates those modules so they need to
# be passed back into lowering. So we can't just use `Base.iterate()`. (Put a
# different way, we have a situation which is suited to coroutines but we
# don't ... | @@ -33,50 +33,45 @@ end
# how we end up putting this into Base.
struct LoweringIterator{GraphType}
- ctx::MacroExpansionContext{GraphType}
+ # We don't currently use this iterator outside of eval (which should always
+ # use the latest world), but this is necessary for passing it in if we did
+ init_wor... | JuliaLowering/src/eval.jl | 26 | Julia | 0.5 | question | 142 | 51 | 51 | false | [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator | 60,168 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/eval.jl
PR Title: [JuliaLowering] get macro name in `ctx.world`; fix lowering iterator
BEFORE CODE: # * Lowering knows when new modules are required, and may request them with
# `:begin_module`. However `eval()` generates those modules so th... | Having the `world` in both the iterator and a separate parameter is a bit unusual.
Is there a reason it needs to be in the iterator at all? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@chk numchildren(ex) == 2
@ast ctx ex [K"call"
"*"::K"Identifier"(scope_layer=layerid)
expand_forms_1(ctx, ex[1])
expand_forms_1(ctx, ex[2])
]
elseif k == K"quote"
@chk numchildren(ex) == 1
# TODO: Upstream should set a general flag for det... | This seems to change the LineNumberNode slightly (allows `file === nothing`), but I guess we don't use this in lowering right now.
Does this affect anything? | @ast ctx ex [K"call"
"*"::K"Identifier"(scope_layer=layerid)
expand_forms_1(ctx, ex[1])
expand_forms_1(ctx, ex[2])
]
elseif k == K"quote"
@chk numchildren(ex) == 1
# TODO: Upstream should set a general flag for detecting parenthesized
# exp... | @@ -454,6 +453,9 @@ function expand_forms_1(ctx::MacroExpansionContext, ex::SyntaxTree)
end
elseif k == K"macrocall"
expand_macro(ctx, ex)
+ elseif k == K"toplevel" && length(ctx.scope_layer_stack) > 1
+ fix_toplevel_expansion(ctx, ex, current_layer(ctx).mod,
+ ... | JuliaLowering/src/macro_expansion.jl | 26 | Julia | 0.571 | question | 160 | 51 | 51 | false | [JuliaLowering] only hygienic-scope-wrap `toplevel` if unescaped | 60,169 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/macro_expansion.jl
PR Title: [JuliaLowering] only hygienic-scope-wrap `toplevel` if unescaped
BEFORE CODE: @chk numchildren(ex) == 2
@ast ctx ex [K"call"
"*"::K"Identifier"(scope_layer=layerid)
expand_fo... | This seems to change the LineNumberNode slightly (allows `file === nothing`), but I guess we don't use this in lowering right now.
Does this affect anything? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if s[1] === '.'
st_k = K".op="
op = s[2:end-1]
else
st_k = K"op="
op = s[1:end-1]
end
child_exprs = Any[e.args[1], Symbol(op), e.args[2]]
elseif e.head === :comparison
for i = 2:2:length(child_exprs)
op,op_esc = unwr... | ```suggestion
if a1 isa Symbol && a1 === Symbol("@__dot__") | op,op_esc = unwrap_esc(child_exprs[i])
@assert op isa Symbol
op_s = string(op)
if is_dotted_operator(op_s)
child_exprs[i] = Expr(:., op_esc(Symbol(op_s[2:end])))
end
end
elseif e.head === :macrocall
@assert nargs >= 2
... | @@ -277,14 +277,10 @@ function _insert_convert_expr(@nospecialize(e), graph::SyntaxGraph, src::SourceA
src = child_exprs[2]
end
deleteat!(child_exprs, 2)
- if a1 isa Symbol
- child_exprs[1] = a1_esc(Expr(:macro_name, a1))
- elseif a1 isa Expr && a1.head === :(.)
-... | JuliaLowering/src/compat.jl | 26 | Julia | 0.571 | suggestion | 68 | 51 | 51 | false | [JuliaLowering] Reconstruct macro name before, not during, macro expansion | 60,170 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/compat.jl
PR Title: [JuliaLowering] Reconstruct macro name before, not during, macro expansion
BEFORE CODE: if s[1] === '.'
st_k = K".op="
op = s[2:end-1]
else
st_k = K"op="
op = ... | ```suggestion
if a1 isa Symbol && a1 === Symbol("@__dot__") | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
## MersenneTwister
const MT_CACHE_F = 501 << 1 # number of Float64 in the cache
const MT_CACHE_I = 501 << 4 # number of bytes in the UInt128 cache
@assert dsfmt_get_min_array_size() <= MT_CACHE_F
mutable struct MersenneTwister <: Abstract... | does a `MersenneTwister` really need to store it's seed? | # This file is a part of Julia. License is MIT: https://julialang.org/license
## MersenneTwister
const MT_CACHE_F = 501 << 1 # number of Float64 in the cache
const MT_CACHE_I = 501 << 4 # number of bytes in the UInt128 cache
@assert dsfmt_get_min_array_size() <= MT_CACHE_F
mutable struct MersenneTwister <: Abstract... | @@ -9,9 +9,9 @@ const MT_CACHE_I = 501 << 4 # number of bytes in the UInt128 cache
mutable struct MersenneTwister <: AbstractRNG
seed::Any | stdlib/Random/src/MersenneTwister.jl | 11 | Julia | 0.357 | question | 56 | 36 | 36 | false | MersenneTwister: clean up constructors | 60,185 | JuliaLang/julia | 35,573 | Julia | oscardssmith | rfourquet | Review this pull request change.
Language: Julia
File: stdlib/Random/src/MersenneTwister.jl
PR Title: MersenneTwister: clean up constructors
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
## MersenneTwister
const MT_CACHE_F = 501 << 1 # number of Float64 in the cache
co... | does a `MersenneTwister` really need to store it's seed? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
input_color(r::StreamREPL) = r.input_color
# heuristic function to decide if the presence of a semicolon
# at the end of the expression was intended for suppressing output
function ends_with_semicolon(code)
semi = false
for tok in tokenize(code)
kind(tok) in KSet"Whitespace NewlineWs Comment EndMarker"... | The specific failure that was getting swallowed and turned into a deadlock was this (courtesy of @xal-0):
```
Unhandled Task ERROR: UndefVarError: `TAGGED_RELEASE_BANNER` not defined in `REPL`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] banner(io::IO, preferred::Symbol)
@ REPL ~/c/juli... | input_color(r::StreamREPL) = r.input_color
# heuristic function to decide if the presence of a semicolon
# at the end of the expression was intended for suppressing output
function ends_with_semicolon(code)
semi = false
for tok in tokenize(code)
kind(tok) in KSet"Whitespace NewlineWs Comment EndMarker"... | @@ -1704,21 +1704,11 @@ function ends_with_semicolon(code)
return semi
end
-"""
- banner(io::IO = stdout, preferred::Symbol = :full)
-
-Print the "Julia" informative banner to `io`, using the `preferred` variant
-if reasonable and known.
-
-!!! warning
- The particular banner selected by `preferred` is li... | stdlib/REPL/src/REPL.jl | 26 | Julia | 1 | bug | 767 | 51 | 51 | false | [release-1.13] Revert "Make banner size depend on terminal size (#51811)" | 60,186 | JuliaLang/julia | 35,573 | Julia | ararslan | ararslan | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/REPL.jl
PR Title: [release-1.13] Revert "Make banner size depend on terminal size (#51811)"
BEFORE CODE: input_color(r::StreamREPL) = r.input_color
# heuristic function to decide if the presence of a semicolon
# at the end of the expression was... | The specific failure that was getting swallowed and turned into a deadlock was this (courtesy of @xal-0):
```
Unhandled Task ERROR: UndefVarError: `TAGGED_RELEASE_BANNER` not defined in `REPL`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] banner(io::IO, preferred::Symbol)
@ REPL ~/c/juli... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
src1 = get(SyntaxTree(graph1, id1), :source, nothing)
src2 = if !copy_source
src1
elseif src1 isa NodeId
_copy_ast(graph2, graph1, src1, seen, copy_source)
elseif src1 isa Tuple
map(i->_copy_ast(graph2, graph1, i, seen, copy_source), src1)
else
src1
end
copy_a... | ```suggestion
attrs = Pair{Symbol,LayerId}[
:scope_layer=>(force ? layer_id : get(ex, :scope_layer, layer_id))
]
```
if you're really trying to be strict about specializations, it can be a good idea to explicitly type most arrays, since:
1. `Pair` over-specializes just like `NamedTuple` (so the ... | let copied = get(seen, id1, nothing)
isnothing(copied) || return copied
end
id2 = newnode!(graph2)
seen[id1] = id2
src1 = get(SyntaxTree(graph1, id1), :source, nothing)
src2 = if !copy_source
src1
elseif src1 isa NodeId
_copy_ast(graph2, graph1, src1, seen, copy_sourc... | @@ -490,19 +505,16 @@ end
#-------------------------------------------------------------------------------
function set_scope_layer(ctx, ex, layer_id, force)
k = kind(ex)
- scope_layer = force ? layer_id : get(ex, :scope_layer, layer_id)
+ attrs = [:scope_layer=>(force ? layer_id : get(ex, :scope_layer, la... | JuliaLowering/src/ast.jl | 26 | Julia | 0.929 | suggestion | 536 | 51 | 51 | false | [JuliaLowering] Tidy up node creation functions | 60,191 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/ast.jl
PR Title: [JuliaLowering] Tidy up node creation functions
BEFORE CODE: src1 = get(SyntaxTree(graph1, id1), :source, nothing)
src2 = if !copy_source
src1
elseif src1 isa NodeId
_copy_ast(graph2, graph1, src1, ... | ```suggestion
attrs = Pair{Symbol,LayerId}[
:scope_layer=>(force ? layer_id : get(ex, :scope_layer, layer_id))
]
```
if you're really trying to be strict about specializations, it can be a good idea to explicitly type most arrays, since:
1. `Pair` over-specializes just like `NamedTuple` (so the ... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
_copy_ast(graph2, graph1, src1, seen, copy_source)
elseif src1 isa Tuple
map(i->_copy_ast(graph2, graph1, i, seen, copy_source), src1)
else
src1
end
copy_attrs!(SyntaxTree(graph2, id2), SyntaxTree(graph1, id1), true)
setattr!(graph2, id2, :source, src2)
if !is_leaf(graph1... | ```suggestion
children = NodeId[set_scope_layer(ctx, ex[1], layer_id, force), ex[2]]
```
see above
| seen[id1] = id2
src1 = get(SyntaxTree(graph1, id1), :source, nothing)
src2 = if !copy_source
src1
elseif src1 isa NodeId
_copy_ast(graph2, graph1, src1, seen, copy_source)
elseif src1 isa Tuple
map(i->_copy_ast(graph2, graph1, i, seen, copy_source), src1)
else
src... | @@ -490,19 +505,16 @@ end
#-------------------------------------------------------------------------------
function set_scope_layer(ctx, ex, layer_id, force)
k = kind(ex)
- scope_layer = force ? layer_id : get(ex, :scope_layer, layer_id)
+ attrs = [:scope_layer=>(force ? layer_id : get(ex, :scope_layer, la... | JuliaLowering/src/ast.jl | 26 | Julia | 0.714 | suggestion | 113 | 51 | 51 | false | [JuliaLowering] Tidy up node creation functions | 60,191 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/ast.jl
PR Title: [JuliaLowering] Tidy up node creation functions
BEFORE CODE: _copy_ast(graph2, graph1, src1, seen, copy_source)
elseif src1 isa Tuple
map(i->_copy_ast(graph2, graph1, i, seen, copy_source), src1)
else
... | ```suggestion
children = NodeId[set_scope_layer(ctx, ex[1], layer_id, force), ex[2]]
```
see above
| You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
else
src1
end
copy_attrs!(SyntaxTree(graph2, id2), SyntaxTree(graph1, id1), true)
setattr!(graph2, id2, :source, src2)
if !is_leaf(graph1, id1)
cs = NodeId[]
for cid in children(graph1, id1)
push!(cs, _copy_ast(graph2, graph1, cid, seen, copy_source))
end
... | It looks like this method doesn't exist, unless I misread something? | src1
elseif src1 isa NodeId
_copy_ast(graph2, graph1, src1, seen, copy_source)
elseif src1 isa Tuple
map(i->_copy_ast(graph2, graph1, i, seen, copy_source), src1)
else
src1
end
copy_attrs!(SyntaxTree(graph2, id2), SyntaxTree(graph1, id1), true)
setattr!(graph2, id... | @@ -490,19 +505,16 @@ end
#-------------------------------------------------------------------------------
function set_scope_layer(ctx, ex, layer_id, force)
k = kind(ex)
- scope_layer = force ? layer_id : get(ex, :scope_layer, layer_id)
+ attrs = [:scope_layer=>(force ? layer_id : get(ex, :scope_layer, la... | JuliaLowering/src/ast.jl | 26 | Julia | 0.214 | question | 68 | 51 | 51 | false | [JuliaLowering] Tidy up node creation functions | 60,191 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/ast.jl
PR Title: [JuliaLowering] Tidy up node creation functions
BEFORE CODE: else
src1
end
copy_attrs!(SyntaxTree(graph2, id2), SyntaxTree(graph1, id1), true)
setattr!(graph2, id2, :source, src2)
if !is_leaf(graph1... | It looks like this method doesn't exist, unless I misread something? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if newchild == e
continue
else
cs = SyntaxList(ctx)
append!(cs, orig_children[1:i-1])
end
end
push!(cs::SyntaxList, newchild)
end
if isnothing(cs)
# This function should be allocation-free if no children ... | narrowing this to `Vector{NodeId}` would be a good idea, if it's possible | orig_children = children(ex)
cs = nothing
for (i,e) in enumerate(orig_children)
newchild = do_map_child(i) ? f(e) : e
if isnothing(cs)
if newchild == e
continue
else
cs = SyntaxList(ctx)
append!(cs, orig_children[1:i-1])... | @@ -417,14 +434,12 @@ function mapchildren(f::Function, ctx, ex::SyntaxTree, do_map_child::Function;
return ex
end
cs::SyntaxList
- ex2 = makenode(ctx, ex, head(ex), cs)
- copy_attrs!(ex2, ex)
- setattr!(ex2; extra_attrs...)
+ ex2 = makenode(ctx, ex, ex, cs)
return ex2
end
-functi... | JuliaLowering/src/ast.jl | 26 | Julia | 0.357 | suggestion | 73 | 51 | 51 | false | [JuliaLowering] Tidy up node creation functions | 60,191 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/ast.jl
PR Title: [JuliaLowering] Tidy up node creation functions
BEFORE CODE: if newchild == e
continue
else
cs = SyntaxList(ctx)
append!(cs, orig_children[1:i-1])
... | narrowing this to `Vector{NodeId}` would be a good idea, if it's possible | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for v in vals
_push_nodeid!(graph, ids, v)
end
end
function _append_nodeids!(graph::SyntaxGraph, ids::Vector{NodeId}, vals::SyntaxList)
check_compatible_graph(graph, vals)
append!(ids, vals.ids)
end
function makeleaf(graph::SyntaxGraph, srcref, proto::Union{Kind, SyntaxTree})
id = newnode!(... | Another normalization trick you might consider trying out at some point is:
```julia
@noinline function _makeleaf(..., attrs::Vector{Any})
# ... (complicated function)
end
@inline function makeleaf(..., @nospecialize(attrs::AbstractVector))
return _makeleaf(..., convert(Vector{Any}, attrs))
end
```
T... | for v in vals
_push_nodeid!(graph, ids, v)
end
end
function _append_nodeids!(graph::SyntaxGraph, ids::Vector{NodeId}, vals::SyntaxList)
check_compatible_graph(graph, vals)
append!(ids, vals.ids)
end
# TODO: "proto", if SyntaxTree, is rarely different from srcref. reorganize to:
# newnode/newlea... | @@ -126,48 +126,49 @@ function _append_nodeids!(graph::SyntaxGraph, ids::Vector{NodeId}, vals::SyntaxL
append!(ids, vals.ids)
end
-function makeleaf(graph::SyntaxGraph, srcref, proto; attrs...)
+function makeleaf(graph::SyntaxGraph, srcref, proto::Union{Kind, SyntaxTree})
id = newnode!(graph)
ex = Syn... | JuliaLowering/src/ast.jl | 26 | Julia | 1 | refactor | 491 | 51 | 51 | false | [JuliaLowering] Tidy up node creation functions | 60,191 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/ast.jl
PR Title: [JuliaLowering] Tidy up node creation functions
BEFORE CODE: for v in vals
_push_nodeid!(graph, ids, v)
end
end
function _append_nodeids!(graph::SyntaxGraph, ids::Vector{NodeId}, vals::SyntaxList)
check_com... | Another normalization trick you might consider trying out at some point is:
```julia
@noinline function _makeleaf(..., attrs::Vector{Any})
# ... (complicated function)
end
@inline function makeleaf(..., @nospecialize(attrs::AbstractVector))
return _makeleaf(..., convert(Vector{Any}, attrs))
end
```
T... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#-------------------------------------------------------------------------------
function set_scope_layer(ctx, ex, layer_id, force)
k = kind(ex)
scope_layer = force ? layer_id : get(ex, :scope_layer, layer_id)
if k == K"module" || k == K"toplevel" || k == K"inert"
makenode(ctx, ex, ex, children(ex);... | I ran JETLS on JuliaLowering today and found this `children` is undefined. | elseif src1 isa NodeId
_copy_ast(graph2, graph1, src1, seen, copy_source)
elseif src1 isa Tuple
map(i->_copy_ast(graph2, graph1, i, seen, copy_source), src1)
else
src1
end
copy_attrs!(SyntaxTree(graph2, id2), SyntaxTree(graph1, id1), true)
setattr!(graph2, id2, :source, s... | @@ -491,20 +510,19 @@ end
#-------------------------------------------------------------------------------
function set_scope_layer(ctx, ex, layer_id, force)
k = kind(ex)
- scope_layer = force ? layer_id : get(ex, :scope_layer, layer_id)
- if k == K"module" || k == K"toplevel" || k == K"inert"
- mak... | JuliaLowering/src/ast.jl | 26 | Julia | 0.5 | suggestion | 74 | 51 | 51 | false | [JuliaLowering] Tidy up node creation functions | 60,191 | JuliaLang/julia | 35,573 | Julia | aviatesk | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/ast.jl
PR Title: [JuliaLowering] Tidy up node creation functions
BEFORE CODE: #-------------------------------------------------------------------------------
function set_scope_layer(ctx, ex, layer_id, force)
k = kind(ex)
scope_layer ... | I ran JETLS on JuliaLowering today and found this `children` is undefined. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
@test p("public[7] = 5") == Expr(:(=), Expr(:ref, :public, 7), 5)
@test p("public() = 6") == Expr(:(=), Expr(:call, :public), Expr(:block, 6))
end
@testset "removing argument sideeffects" begin
# Allow let blocks in broadcasted LHSes, but only evaluate them once:
execs = 0
array = [1]
let x = a... | Should this function do something with the kw, to make sure it actually as the right value? | @test p("public[7] = 5") == Expr(:(=), Expr(:ref, :public, 7), 5)
@test p("public() = 6") == Expr(:(=), Expr(:call, :public), Expr(:block, 6))
end
@testset "removing argument side effects" begin
# Allow let blocks in broadcasted LHSes, but only evaluate them once:
execs = 0
array = [1]
let x = ... | @@ -3746,6 +3746,15 @@ end
let; execs += 1; array; end::Vector{Int} .= 7
@test array == [7]
@test execs == 4
+
+ # remove argument side effects on lhs kwcall
+ pa_execs = 0
+ kw_execs = 0
+ f60152(v, pa; kw) = copy(v)
+ @test (f60152([1, 2, 3], 0; kw=0) .*= 2) == [2,4,6] | test/syntax.jl | 26 | Julia | 0.286 | question | 91 | 51 | 51 | false | Fix `remove-argument-side-effects` with keyword call | 60,195 | JuliaLang/julia | 35,573 | Julia | Keno | mlechu | Review this pull request change.
Language: Julia
File: test/syntax.jl
PR Title: Fix `remove-argument-side-effects` with keyword call
BEFORE CODE: @test p("public[7] = 5") == Expr(:(=), Expr(:ref, :public, 7), 5)
@test p("public() = 6") == Expr(:(=), Expr(:call, :public), Expr(:block, 6))
end
@testset "remo... | Should this function do something with the kw, to make sure it actually as the right value? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Future{Any}(call, interp, sv) do call, _, sv
# this only is needed for the side-effect, sequenced before any task tries to consume the return value,
# which this will do even without returning this Future
sv.stmt_info[sv.currpc] = call.info
nothing
end
return call
end
functi... | I would add a type-assert to avoid invalidations, see https://github.com/JuliaLang/julia/pull/59886:
```suggestion
dt.layout::Ptr{Cvoid} == C_NULL && return false
``` | Future{Any}(call, interp, sv) do call, _, sv
# this only is needed for the side-effect, sequenced before any task tries to consume the return value,
# which this will do even without returning this Future
sv.stmt_info[sv.currpc] = call.info
nothing
end
return call
end
functi... | @@ -3079,6 +3079,13 @@ function abstract_eval_call(interp::AbstractInterpreter, e::Expr, sstate::Statem
end
end
+function is_field_pointerfree(dt::DataType, fidx::Int)
+ dt.layout == C_NULL && return false | Compiler/src/abstractinterpretation.jl | 26 | Julia | 0.929 | suggestion | 170 | 51 | 51 | false | Finish PR: inference: fix the ptrfree field check | 60,214 | JuliaLang/julia | 35,573 | Julia | JamesWrigley | MasonProtter | Review this pull request change.
Language: Julia
File: Compiler/src/abstractinterpretation.jl
PR Title: Finish PR: inference: fix the ptrfree field check
BEFORE CODE: Future{Any}(call, interp, sv) do call, _, sv
# this only is needed for the side-effect, sequenced before any task tries to consume the re... | I would add a type-assert to avoid invalidations, see https://github.com/JuliaLang/julia/pull/59886:
```suggestion
dt.layout::Ptr{Cvoid} == C_NULL && return false
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
"const x = 1" => "(const (= x 1))"
"const x .= 1" => "(error (const (.= x 1)))"
"global x ~ 1" => "(global (call-i x ~ 1))"
"global x += 1" => "(global (op= x + 1))"
"const x" => "(error (const x))"
"global const x" => "(global (error (const x)))"
... | Maybe also insert a involving explicitly a tuple `()` as the body?
E.g. near line 622-628, where in https://github.com/JuliaLang/JuliaSyntax.jl/pull/580 this test was inserted:
```
"function (\n f\n )() end" => "(function (call (parens f)) (block))"
```
well now we want to test something l... | "global x" => "(global x)"
"local x" => "(local x)"
"global x,y" => "(global x y)"
"global const x = 1" => "(global (const (= x 1)))"
"local const x = 1" => "(local (const (= x 1)))"
"const global x = 1" => "(const (global (= x 1)))"
"const local x = 1... | @@ -603,6 +603,7 @@ tests = [
"macro \$f() end" => "(macro (call (\$ f)) (block))"
"macro (\$f)() end" => "(macro (call (parens (\$ f))) (block))"
"function (x) body end"=> "(function (tuple-p x) (block body))"
+ "function (x)\n body\nend"=> "(function (tuple-p x) (block... | JuliaSyntax/test/parser.jl | 26 | Julia | 0.857 | suggestion | 617 | 51 | 51 | false | JuliaSyntax: fix anonymous function parsing | 60,221 | JuliaLang/julia | 35,573 | Julia | fingolfin | IanButterworth | Review this pull request change.
Language: Julia
File: JuliaSyntax/test/parser.jl
PR Title: JuliaSyntax: fix anonymous function parsing
BEFORE CODE: "const x = 1" => "(const (= x 1))"
"const x .= 1" => "(error (const (.= x 1)))"
"global x ~ 1" => "(global (call-i x ~ 1))"
"g... | Maybe also insert a involving explicitly a tuple `()` as the body?
E.g. near line 622-628, where in https://github.com/JuliaLang/JuliaSyntax.jl/pull/580 this test was inserted:
```
"function (\n f\n )() end" => "(function (call (parens f)) (block))"
```
well now we want to test something l... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# function f() end ==> (function (call f))
parse_unary_prefix(ps)
else
# When an initial parenthesis is present, we need to distinguish
# between
# * The function name in parens, followed by (args...)
# * An anonymous function argument lis... | This could be compacted into:
```suggestion
token_after_paren = peek(ps, if first_no_skip == K")"
# Directly before ), token after ) is peek(2)
2
else
# There's whitespace before ), so ) is at peek(2)
# and ... | # function f() end ==> (function (call f))
parse_unary_prefix(ps)
else
# When an initial parenthesis is present, we need to distinguish
# between
# * The function name in parens, followed by (args...)
# * An anonymous function argument lis... | @@ -2218,10 +2218,23 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
opts = parse_brackets(ps, K")") do had_commas, had_splat, num_semis, num_subexprs
_parsed_call = was_eventually_call(ps)
_maybe_grouping_parens = !had_commas && !had_splat && num_s... | JuliaSyntax/src/julia/parser.jl | 26 | Julia | 0.857 | question | 485 | 51 | 51 | false | JuliaSyntax: fix anonymous function parsing | 60,221 | JuliaLang/julia | 35,573 | Julia | fogti | IanButterworth | Review this pull request change.
Language: Julia
File: JuliaSyntax/src/julia/parser.jl
PR Title: JuliaSyntax: fix anonymous function parsing
BEFORE CODE: # function f() end ==> (function (call f))
parse_unary_prefix(ps)
else
# When an initial parenthesis is present, we n... | This could be compacted into:
```suggestion
token_after_paren = peek(ps, if first_no_skip == K")"
# Directly before ), token after ) is peek(2)
2
else
# There's whitespace before ), so ) is at peek(2)
# and ... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# between
# * The function name in parens, followed by (args...)
# * An anonymous function argument list in parens
# * The whole function declaration, in parens
bump(ps, TRIVIA_FLAG)
is_empty_tuple = peek(ps, skip_newlines=true) == K")"
... | I think it would make a lot of sense to split the logic with a case distinction on `_maybe_grouping_parens`:
```suggestion
next_kind = if _maybe_grouping_parens
# Check if there's a newline between `)` and the next `(` or `.`.
# We need to find where `)` is and c... | # between
# * The function name in parens, followed by (args...)
# * An anonymous function argument list in parens
# * The whole function declaration, in parens
bump(ps, TRIVIA_FLAG)
is_empty_tuple = peek(ps, skip_newlines=true) == K")"
... | @@ -2218,10 +2218,23 @@ function parse_function_signature(ps::ParseState, is_function::Bool)
opts = parse_brackets(ps, K")") do had_commas, had_splat, num_semis, num_subexprs
_parsed_call = was_eventually_call(ps)
_maybe_grouping_parens = !had_commas && !had_splat && num_s... | JuliaSyntax/src/julia/parser.jl | 26 | Julia | 0.786 | suggestion | 1,421 | 51 | 51 | false | JuliaSyntax: fix anonymous function parsing | 60,221 | JuliaLang/julia | 35,573 | Julia | fogti | IanButterworth | Review this pull request change.
Language: Julia
File: JuliaSyntax/src/julia/parser.jl
PR Title: JuliaSyntax: fix anonymous function parsing
BEFORE CODE: # between
# * The function name in parens, followed by (args...)
# * An anonymous function argument list in parens
... | I think it would make a lot of sense to split the logic with a case distinction on `_maybe_grouping_parens`:
```suggestion
next_kind = if _maybe_grouping_parens
# Check if there's a newline between `)` and the next `(` or `.`.
# We need to find where `)` is and c... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for i in first_trailing_arg:length(gen_arg_names)
gen_arg_names[i] = setmeta(gen_arg_names[i]; nospecialize=true)
push!(gen_arg_types, @ast ctx gen_arg_names[i] "Any"::K"core")
end
# Code generator definition
gen_func_method_defs = @ast ctx srcref [K"block"
[K"function_decl" gen_... | I have probably missed some kinds here - @mlechu do you know the full list? | for i in first_trailing_arg:length(gen_arg_names)
gen_arg_names[i] = setmeta(gen_arg_names[i]; nospecialize=true)
push!(gen_arg_types, @ast ctx gen_arg_names[i] "Any"::K"core")
end
# Code generator definition
gen_func_method_defs = @ast ctx srcref [K"block"
[K"function_decl" gen_... | @@ -2534,6 +2534,14 @@ function expand_function_generator(ctx, srcref, callex_srcref, func_name, func_n
]
]
+ function stub_argname(n::SyntaxTree)
+ if kind(n) == K"Identifier"
+ return n.name_val::String
+ elseif kind(n) == K"BindingId"
+ return "#unused#"
+ ... | JuliaLowering/src/desugaring.jl | 26 | Julia | 0.214 | question | 75 | 51 | 51 | false | [JuliaLowering] Fix handling of unnamed args in `@generated` functions | 60,226 | JuliaLang/julia | 35,573 | Julia | topolarity | topolarity | Review this pull request change.
Language: Julia
File: JuliaLowering/src/desugaring.jl
PR Title: [JuliaLowering] Fix handling of unnamed args in `@generated` functions
BEFORE CODE: for i in first_trailing_arg:length(gen_arg_names)
gen_arg_names[i] = setmeta(gen_arg_names[i]; nospecialize=true)
p... | I have probably missed some kinds here - @mlechu do you know the full list? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# whatever code comes from the user's generator into an appropriate
# K"lambda" (+ K"with_static_parameters") suitable for lowering
# into a CodeInfo.
#
# todo: As isolated top-level code, we don't actually want to apply
# the normal scope rules of... | Do we need this for static parameters too? (Underscores are usable as static parameters, but is that even intended?) | "generated"::K"Symbol"
# The following is code to be evaluated at top level and will wrap
# whatever code comes from the user's generator into an appropriate
# K"lambda" (+ K"with_static_parameters") suitable for lowering
# into a CodeInfo.
#
... | JuliaLowering/src/desugaring.jl | 26 | Julia | 0.357 | question | 117 | 51 | 51 | false | [JuliaLowering] Fix handling of unnamed args in `@generated` functions | 60,226 | JuliaLang/julia | 35,573 | Julia | mlechu | topolarity | Review this pull request change.
Language: Julia
File: JuliaLowering/src/desugaring.jl
PR Title: [JuliaLowering] Fix handling of unnamed args in `@generated` functions
BEFORE CODE: # whatever code comes from the user's generator into an appropriate
# K"lambda" (+ K"with_static_parameters") s... | Do we need this for static parameters too? (Underscores are usable as static parameters, but is that even intended?) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. | |
6 (call core.Typeof %₅)
7 (call core.svec %₆ JuliaLowering.MacroContext core.Any core.Any core.Any core.Any)
8 (call core.svec)
9 SourceLocation::1:21
10 (call core.svec %₇ %₈ %₉)
11 --- method core.nothing %₁₀
slots: [slot₁/#self#(!read) slot₂/__context__(!read) slot₃/#self#(!read) slot₄/#arg1#(!read) sl... | Best we don't add more generated function IR tests—I've been meaning to remove the ones we have, or at least change them to print less. This particular line will trigger a diff with all sorts of irrelevant parsing or SourceRef changes. | (nongen_stuff, maybe_gen_stuff)
end
#---------------------
1 (method TestMod.f_partially_generated)
2 latestworld
3 (method TestMod.#f_partially_generated@generator#0)
4 latestworld
5 TestMod.#f_partially_generated@generator#0
6 (call core.Typeof %₅)
7 (call core.svec %₆ JuliaLowering.MacroContext cor... | @@ -1566,6 +1566,49 @@ end
21 TestMod.f_only_generated
22 (return %₂₁)
+########################################
+# Fully generated function with unnamed arguments
+@generated function f_generated_unnamed_args(::Type{Int}, y, ::Type{Float64})
+ generator_code(y)
+end
+#---------------------
+1 (method TestMo... | JuliaLowering/test/functions_ir.jl | 26 | Julia | 0.5 | style | 236 | 51 | 41 | false | [JuliaLowering] Fix handling of unnamed args in `@generated` functions | 60,226 | JuliaLang/julia | 35,573 | Julia | mlechu | topolarity | Review this pull request change.
Language: Julia
File: JuliaLowering/test/functions_ir.jl
PR Title: [JuliaLowering] Fix handling of unnamed args in `@generated` functions
BEFORE CODE: 6 (call core.Typeof %₅)
7 (call core.svec %₆ JuliaLowering.MacroContext core.Any core.Any core.Any core.Any)
8 (call core.svec... | Best we don't add more generated function IR tests—I've been meaning to remove the ones we have, or at least change them to print less. This particular line will trigger a diff with all sorts of irrelevant parsing or SourceRef changes. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
sig = _deref_ssa(stmts, e[2])
@assert kind(sig) == K"call"
arg_types = _deref_ssa(stmts, sig[2])
@assert kind(arg_types) == K"call"
self_type = _deref_ssa(stmts, arg_types[2])
if kind(self_type) == K"globalref" && occursin(name, self_type.name_val)... | +1, that would definitely help with getting the test suite to pass when JuliaLowering is included in Base | sig = _deref_ssa(stmts, e[2])
@assert kind(sig) == K"call"
arg_types = _deref_ssa(stmts, sig[2])
@assert kind(arg_types) == K"call"
self_type = _deref_ssa(stmts, arg_types[2])
if kind(self_type) == K"globalref" && occursin(name, self_type.name_val)... | @@ -118,6 +118,7 @@ function print_ir(io::IO, ex, method_filter=nothing)
_print_ir(io, ex, "")
end
+# TODO: JuliaLowering-the-module should always print the same way, ignoring parent modules | JuliaLowering/src/utils.jl | 26 | Julia | 0.357 | suggestion | 105 | 51 | 51 | false | [JuliaLowering] Fix generated functions when `expr_compat_mode=true` | 60,233 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/utils.jl
PR Title: [JuliaLowering] Fix generated functions when `expr_compat_mode=true`
BEFORE CODE: sig = _deref_ssa(stmts, e[2])
@assert kind(sig) == K"call"
arg_types = _deref_ssa(stmts, sig[2])
... | +1, that would definitely help with getting the test suite to pass when JuliaLowering is included in Base | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
# they all effectively be resolved into GlobalRef earlier?
Symbol(ex.name_val)
elseif k == K"SourceLocation"
QuoteNode(source_location(LineNumberNode, ex))
elseif k == K"Symbol"
QuoteNode(Symbol(ex.name_val))
elseif k == K"slot"
Core.SlotNumber(ex.var_id)
elseif k... | Is this supposed to be a check for whether `ex.value` is self-quoting?
probably worth review / clean-up when we fix the outstanding JL issues with quoting:
```julia
julia> macro quoted_globalref(); QuoteNode(GlobalRef(Base, :Int)); end;
julia> JuliaLowering.include_string(Main, "@quoted_globalref"; expr_compat_mo... | # they all effectively be resolved into GlobalRef earlier?
Symbol(ex.name_val)
elseif k == K"SourceLocation"
QuoteNode(source_location(LineNumberNode, ex))
elseif k == K"Symbol"
QuoteNode(Symbol(ex.name_val))
elseif k == K"slot"
Core.SlotNumber(ex.var_id)
elseif k... | @@ -370,7 +370,7 @@ function _to_lowered_expr(ex::SyntaxTree, stmt_offset::Int)
ir
end
elseif k == K"Value"
- ex.value
+ ex.value isa LineNumberNode ? QuoteNode(ex.value) : ex.value | JuliaLowering/src/eval.jl | 26 | Julia | 0.857 | question | 364 | 51 | 51 | false | [JuliaLowering] Fix generated functions when `expr_compat_mode=true` | 60,233 | JuliaLang/julia | 35,573 | Julia | topolarity | mlechu | Review this pull request change.
Language: Julia
File: JuliaLowering/src/eval.jl
PR Title: [JuliaLowering] Fix generated functions when `expr_compat_mode=true`
BEFORE CODE: # they all effectively be resolved into GlobalRef earlier?
Symbol(ex.name_val)
elseif k == K"SourceLocation"
QuoteN... | Is this supposed to be a check for whether `ex.value` is self-quoting?
probably worth review / clean-up when we fix the outstanding JL issues with quoting:
```julia
julia> macro quoted_globalref(); QuoteNode(GlobalRef(Base, :Int)); end;
julia> JuliaLowering.include_string(Main, "@quoted_globalref"; expr_compat_mo... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
size_t nb = jl_datatype_size(ety);
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE)
jl_error("atomic_pointerreplace: invalid pointer for atomic operation");
int isptr = jl_field_isptr(rettyp, 0);
jl_task_t *ct = jl_current_task;
result = jl_gc_alloc(ct->ptls, ... | Missing `jl_get_atomic_order_checked` call on this code path | size_t nb = jl_datatype_size(ety);
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE)
jl_error("atomic_pointerreplace: invalid pointer for atomic operation");
int isptr = jl_field_isptr(rettyp, 0);
jl_task_t *ct = jl_current_task;
result = jl_gc_alloc(ct->ptls, ... | @@ -622,9 +622,16 @@ JL_DLLEXPORT jl_value_t *jl_atomic_pointerreplace(jl_value_t *p, jl_value_t *exp
return result;
}
-JL_DLLEXPORT jl_value_t *jl_atomic_fence(jl_value_t *order_sym)
+JL_DLLEXPORT jl_value_t *jl_atomic_fence(jl_value_t *order_sym, jl_value_t *syncscope_sym)
{
JL_TYPECHK(fence, symbol, or... | src/runtime_intrinsics.c | 26 | C | 0.357 | suggestion | 60 | 51 | 51 | false | threads: Implement asymmetric atomic fences | 60,311 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: C
File: src/runtime_intrinsics.c
PR Title: threads: Implement asymmetric atomic fences
BEFORE CODE: size_t nb = jl_datatype_size(ety);
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE)
jl_error("atomic_pointerreplace: invalid pointer for ... | Missing `jl_get_atomic_order_checked` call on this code path | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if (threadid % 2) == 0
@atomic :monotonic data.x[it] = 1
Threads.atomic_fence_heavy()
@atomic :monotonic data.read_y[it] = @atomic :monotonic data.y[it]
wait(cond1)
notify(cond2)
else
@atomic :monotonic data.y[it] = 1
Threads.atomic_fence_light()
@... | ```suggestion
data = AsymmetricFenceTestData(AtomicMemory{Int}(undef, asymmetric_test_count),
AtomicMemory{Int}(undef, asymmetric_test_count),
AtomicMemory{Int}(undef, asymmetric_test_count),
AtomicMemory{In... | if (threadid % 2) == 0
@atomic :monotonic data.x[it] = 1
Threads.atomic_fence_heavy()
@atomic :monotonic data.read_y[it] = @atomic :monotonic data.y[it]
wait(cond1)
notify(cond2)
else
@atomic :monotonic data.y[it] = 1
Threads.atomic_fence_light()
@... | @@ -464,6 +464,54 @@ function test_fence()
end
test_fence()
+# Test asymmetric thread fences
+const asymmetric_test_count = 200_000
+struct AsymmetricFenceTestData
+ x::AtomicMemory{Int}
+ y::AtomicMemory{Int}
+ read_x::AtomicMemory{Int}
+ read_y::AtomicMemory{Int}
+end
+function test_asymmetric_fence(d... | test/threads_exec.jl | 26 | Julia | 0.929 | suggestion | 358 | 51 | 51 | false | threads: Implement asymmetric atomic fences | 60,311 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: Julia
File: test/threads_exec.jl
PR Title: threads: Implement asymmetric atomic fences
BEFORE CODE: if (threadid % 2) == 0
@atomic :monotonic data.x[it] = 1
Threads.atomic_fence_heavy()
@atomic :monotonic data.read_y[it] = @atomic :monotonic dat... | ```suggestion
data = AsymmetricFenceTestData(AtomicMemory{Int}(undef, asymmetric_test_count),
AtomicMemory{Int}(undef, asymmetric_test_count),
AtomicMemory{Int}(undef, asymmetric_test_count),
AtomicMemory{In... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
timerprof.tv_sec = nsecprof/GIGA;
timerprof.tv_nsec = nsecprof%GIGA;
profile_running = 1;
profile_all_tasks = all_tasks;
// ensure the alarm is running
ret = clock_alarm(clk, TIME_RELATIVE, timerprof, profile_port);
HANDLE_MACH_ERROR("clock_alarm", ret);
return 0;
}
JL_DLLEXPOR... | We should probably add this to THIRDPARTY.md. I don't know if this is enough code to qualify as copywrite, but we might as well give the acknowledgment credit there since that is all MIT asks for. | }
timerprof.tv_sec = nsecprof/GIGA;
timerprof.tv_nsec = nsecprof%GIGA;
profile_running = 1;
profile_all_tasks = all_tasks;
// ensure the alarm is running
ret = clock_alarm(clk, TIME_RELATIVE, timerprof, profile_port);
HANDLE_MACH_ERROR("clock_alarm", ret);
return 0;
}
JL_DLLEXPOR... | @@ -891,3 +892,54 @@ JL_DLLEXPORT void jl_profile_stop_timer(void)
profile_all_tasks = 0;
uv_mutex_unlock(&bt_data_prof_lock);
}
+
+// The mprotect implementation in signals-unix.c does not work on macOS/aarch64, as mentioned.
+// This implementation comes from dotnet, but is similarly dependent on undocumen... | src/signals-mach.c | 26 | C | 0.429 | suggestion | 196 | 51 | 51 | false | threads: Implement asymmetric atomic fences | 60,311 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: C
File: src/signals-mach.c
PR Title: threads: Implement asymmetric atomic fences
BEFORE CODE: }
timerprof.tv_sec = nsecprof/GIGA;
timerprof.tv_nsec = nsecprof%GIGA;
profile_running = 1;
profile_all_tasks = all_tasks;
// ensure the alarm is running... | We should probably add this to THIRDPARTY.md. I don't know if this is enough code to qualify as copywrite, but we might as well give the acknowledgment credit there since that is all MIT asks for. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
profile_running = 1;
profile_all_tasks = all_tasks;
// ensure the alarm is running
ret = clock_alarm(clk, TIME_RELATIVE, timerprof, profile_port);
HANDLE_MACH_ERROR("clock_alarm", ret);
return 0;
}
JL_DLLEXPORT void jl_profile_stop_timer(void)
{
uv_mutex_lock(&bt_data_prof_lock);
profi... | This seems a little heavyweight, since we already have these values in `jl_all_tls_states`, since we use them elsewhere in this file (`pthread_mach_thread_np(ptls2->system_id)`) | profile_running = 1;
profile_all_tasks = all_tasks;
// ensure the alarm is running
ret = clock_alarm(clk, TIME_RELATIVE, timerprof, profile_port);
HANDLE_MACH_ERROR("clock_alarm", ret);
return 0;
}
JL_DLLEXPORT void jl_profile_stop_timer(void)
{
uv_mutex_lock(&bt_data_prof_lock);
profi... | @@ -891,3 +892,54 @@ JL_DLLEXPORT void jl_profile_stop_timer(void)
profile_all_tasks = 0;
uv_mutex_unlock(&bt_data_prof_lock);
}
+
+// The mprotect implementation in signals-unix.c does not work on macOS/aarch64, as mentioned.
+// This implementation comes from dotnet, but is similarly dependent on undocumen... | src/signals-mach.c | 26 | C | 0.714 | suggestion | 177 | 51 | 51 | false | threads: Implement asymmetric atomic fences | 60,311 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: C
File: src/signals-mach.c
PR Title: threads: Implement asymmetric atomic fences
BEFORE CODE: profile_running = 1;
profile_all_tasks = all_tasks;
// ensure the alarm is running
ret = clock_alarm(clk, TIME_RELATIVE, timerprof, profile_port);
HANDLE_MACH_... | This seems a little heavyweight, since we already have these values in `jl_all_tls_states`, since we use them elsewhere in this file (`pthread_mach_thread_np(ptls2->system_id)`) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return raise(SIGTSTP);
}
// Linux and FreeBSD have compatible membarrier support
#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_)
#if defined(_OS_LINUX_)
# include <sys/syscall.h>
# if defined(__has_include)
# if __has_include(<linux/membarrier.h>)
# include <linux/membarrier.h>
# define membarrier(.... | Should we simplify this to always take the `if defined(__NR_membarrier)` path? It looks slightly odd that if `__has_include` isn't defined, then we just assume the header is available instead of defining it always in this file
For the most part (similar to libuv policy), we should try to limit how often we do compil... | return raise(SIGTSTP);
}
#if !defined(_OS_DARWIN_)
// Thread suspension based membarrier fallback.
// This is a sound but slow implementation that suspends and resumes each thread
// to force them to execute memory barriers via the signal handling mechanism.
// This is used as a fallback when neither the membarrie... | @@ -1274,3 +1274,128 @@ JL_DLLEXPORT int jl_repl_raise_sigtstp(void)
{
return raise(SIGTSTP);
}
+
+// Linux and FreeBSD have compatible membarrier support
+#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_)
+#if defined(_OS_LINUX_)
+# include <sys/syscall.h>
+# if defined(__has_include)
+# if __has_include(<linu... | src/signals-unix.c | 26 | C | 0.643 | refactor | 400 | 51 | 51 | false | threads: Implement asymmetric atomic fences | 60,311 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: C
File: src/signals-unix.c
PR Title: threads: Implement asymmetric atomic fences
BEFORE CODE: return raise(SIGTSTP);
}
// Linux and FreeBSD have compatible membarrier support
#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_)
#if defined(_OS_LINUX_)
# include <sys/sysca... | Should we simplify this to always take the `if defined(__NR_membarrier)` path? It looks slightly odd that if `__has_include` isn't defined, then we just assume the header is available instead of defining it always in this file
For the most part (similar to libuv policy), we should try to limit how often we do compil... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Implementation of the `mprotect` based membarrier fallback.
// This is a common fallback based on the observation that `mprotect` happens to
// issue the necessary memory barriers. However, there is no spec that
// guarantees this behavior, and indeed AArch64 macos does not. However, we
// only use it as a fallback... | ```suggestion
jl_safe_printf("fatal: failed to mlock barrier page (try increasing RLIMIT_MEMLOCK with `ulimit -l`).\n");
``` | // here for older versions of Linux and FreeBSD on x86 where we know that it
// happens to work.
#if !defined(_CPU_AARCH64_) && !defined(_CPU_ARM_)
static pthread_mutex_t mprotect_barrier_lock = PTHREAD_MUTEX_INITIALIZER;
static _Atomic(uint64_t) *mprotect_barrier_page = NULL;
// Returns 1 on success, 0 on failure (e.g... | @@ -1274,3 +1274,128 @@ JL_DLLEXPORT int jl_repl_raise_sigtstp(void)
{
return raise(SIGTSTP);
}
+
+// Linux and FreeBSD have compatible membarrier support
+#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_)
+#if defined(_OS_LINUX_)
+# include <sys/syscall.h>
+# if defined(__has_include)
+# if __has_include(<linu... | src/signals-unix.c | 26 | C | 0.714 | bug | 138 | 51 | 51 | false | threads: Implement asymmetric atomic fences | 60,311 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: C
File: src/signals-unix.c
PR Title: threads: Implement asymmetric atomic fences
BEFORE CODE:
// Implementation of the `mprotect` based membarrier fallback.
// This is a common fallback based on the observation that `mprotect` happens to
// issue the necessary memory barr... | ```suggestion
jl_safe_printf("fatal: failed to mlock barrier page (try increasing RLIMIT_MEMLOCK with `ulimit -l`).\n");
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.