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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
# Run the verifier in the current world (before modifications), so that error
# messages and types print in their usual way.
Core.Compiler._verify_trim_world_age[] = Base.get_world_counter()
# Initialize some things not usually initialized when output is requested
Sys.__init__()
Base.init_depot_path()
Base.init_load_p... | This should be an `IdSet{Any}`. | # Initialize some things not usually initialized when output is requested
Sys.__init__()
Base.reinit_stdio()
Base.init_depot_path()
Base.init_load_path()
Base.init_active_project()
task = current_task()
task.rngState0 = 0x5156087469e170ab
task.rngState1 = 0x7431eaead385992c
task.rngState2 = 0x503e1d32781c2608
task.rngS... | @@ -27,6 +27,30 @@ if Base.JLOptions().trim != 0
include(joinpath(@__DIR__, "juliac-trim-base.jl"))
end
+const C_friendly_types = Union{ # a few of these are redundant to make it easier to maintain | contrib/juliac/juliac-buildscript.jl | 26 | Julia | 0.286 | suggestion | 31 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-buildscript.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: # Run the verifier in the current world (before modifications), so that error
# messages and types print in their usual way.
Core.Compiler._verify_trim_... | This should be an `IdSet{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. |
if Base.get_bool_env("JULIA_USE_FLISP_PARSER", false) === false
Base.JuliaSyntax.enable_in_core!()
end
if Base.JLOptions().trim != 0
include(joinpath(@__DIR__, "juliac-trim-base.jl"))
end
const C_friendly_types = Union{ # a few of these are redundant to make it easier to maintain
Int8, Int16, Int32, In... | For e.g. C, we'll have to do our own name mangling to handle parameters, or maybe just disallow them. Either way the parameters don't really matter here and don't need to be c-compatible. |
include(joinpath(@__DIR__, "abi_export.jl"))
# Load user code
import Base.Experimental.entrypoint
# for use as C main if needed
function _main(argc::Cint, argv::Ptr{Ptr{Cchar}})::Cint
args = ccall(:jl_set_ARGS, Any, (Cint, Ptr{Ptr{Cchar}}), argc, argv)::Vector{String}
setglobal!(Base, :PROGRAM_FILE, args[1]... | @@ -27,6 +27,30 @@ if Base.JLOptions().trim != 0
include(joinpath(@__DIR__, "juliac-trim-base.jl"))
end
+const C_friendly_types = Union{ # a few of these are redundant to make it easier to maintain
+ Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
+ Cvoid, Cint, Cshort... | contrib/juliac/juliac-buildscript.jl | 26 | Julia | 0.5 | suggestion | 187 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-buildscript.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: if Base.get_bool_env("JULIA_USE_FLISP_PARSER", false) === false
Base.JuliaSyntax.enable_in_core!()
end
if Base.JLOptions().trim != 0
include(jo... | For e.g. C, we'll have to do our own name mangling to handle parameters, or maybe just disallow them. Either way the parameters don't really matter here and don't need to be c-compatible. | 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. |
entrypoint(_main, (Cint, Ptr{Ptr{Cchar}}))
Base._ccallable("main", Cint, Tuple{typeof(_main), Cint, Ptr{Ptr{Cchar}}})
else
error("`@main` must accept a `Vector{String}` argument.")
end
else
error("To ... | Would be good to move this to a function. |
# Export info about entrypoints and structs needed to create header files
if length(ARGS) >= 4
abi_export = ARGS[4]
open(abi_export, "w") do io
write_abi_metadata(io)
end
end
end
# Run the verifier in the current world (before build-script modifications),
# so that erro... | @@ -73,6 +96,43 @@ let mod = Base.include(Main, ARGS[1])
if ARGS[3] == "true"
ccall(:jl_add_ccallable_entrypoints, Cvoid, ())
end
+
+ # Export info about entrypoints and structs needed to create header files
+ if length(ARGS) >= 4
+ logfile = ARGS[4]
+ iotmp = IOBuffer()
+ ... | contrib/juliac/juliac-buildscript.jl | 26 | Julia | 0.143 | refactor | 41 | 51 | 34 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-buildscript.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: entrypoint(_main, (Cint, Ptr{Ptr{Cchar}}))
Base._ccallable("main", Cint, Tuple{typeof(_main), Cint, Ptr{Ptr{Ccha... | Would be good to move this to a function. | 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
const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
Cvoid, Cint, Cshort, Clong, Cuint, Cushort, Culong, Cssize_t, Csize_t,
Cchar, Cwchar_t, Cstring, Cwstring,
Raw... | My KISS instinct would be to use a standard serialization format like JSON to print out the type information
Also do we need the `offset` info? No problem with adding it so I'm mostly asking for understanding - IIUC the offsets should be implied by the C ABI on a particular platform |
# for use as C main if needed
function _main(argc::Cint, argv::Ptr{Ptr{Cchar}})::Cint
args = ccall(:jl_set_ARGS, Any, (Cint, Ptr{Ptr{Cchar}}), argc, argv)::Vector{String}
setglobal!(Base, :PROGRAM_FILE, args[1])
popfirst!(args)
append!(Base.ARGS, args)
return Main.main(args)
end
let include_result... | @@ -27,6 +27,62 @@ if Base.JLOptions().trim != 0
include(joinpath(@__DIR__, "juliac-trim-base.jl"))
end
+const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
+ Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
+ Cvoid, C... | contrib/juliac/juliac-buildscript.jl | 26 | Julia | 0.786 | suggestion | 286 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | topolarity | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-buildscript.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: end
const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
Int8, Int16, Int32, Int64, UInt8, UI... | My KISS instinct would be to use a standard serialization format like JSON to print out the type information
Also do we need the `offset` info? No problem with adding it so I'm mostly asking for understanding - IIUC the offsets should be implied by the C ABI on a particular platform | 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. |
Base.visit(Core.GlobalMethods) do method
if isdefined(method, :ccallable)
rt, sig = method.ccallable
name = length(method.ccallable) > 2 ? Symbol(method.ccallable[3]) : method.name
print(IOContext(iotmp, :print_method_signature_only => true), method)
methodstr... | Can we make this a `--export-abi build.json` (or other name - open to bikeshedding) instead of a positional arg? | if !have_cmain
if Base.should_use_main_entrypoint()
if hasmethod(Main.main, Tuple{Vector{String}})
entrypoint(_main, (Cint, Ptr{Ptr{Cchar}}))
Base._ccallable("main", Cint, Tuple{typeof(_main), Cint, Ptr{Ptr{Cchar}}})
else
... | @@ -73,6 +129,14 @@ let mod = Base.include(Main, ARGS[1])
if ARGS[3] == "true"
ccall(:jl_add_ccallable_entrypoints, Cvoid, ())
end
+
+ # Export info about entrypoints and structs needed to create header files
+ if length(ARGS) >= 4 | contrib/juliac/juliac-buildscript.jl | 26 | Julia | 0.571 | question | 112 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | topolarity | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-buildscript.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: Base.visit(Core.GlobalMethods) do method
if isdefined(method, :ccallable)
rt, sig = method.ccallable
name = length(m... | Can we make this a `--export-abi build.json` (or other name - open to bikeshedding) instead of a positional arg? | 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. |
task.rngState4 = 0x5502376d099035ae
uuid_tuple = (UInt64(0), UInt64(0))
ccall(:jl_set_module_uuid, Cvoid, (Any, NTuple{2, UInt64}), Base.__toplevel__, uuid_tuple)
if Base.get_bool_env("JULIA_USE_FLISP_PARSER", false) === false
Base.JuliaSyntax.enable_in_core!()
end
if Base.JLOptions().trim != 0
include(joinpat... | ```suggestion
while T <: Ptr
T = T.parameters[1] # unwrap Ptr{...}
end
if T.name.module === Core && T ∉ C_friendly_types
error("invalid type for juliac: ", T) # exclude internals (they may change)
end
push!(types, T)
```
Mostly just to make the logic more direct, but there... | if Base.get_bool_env("JULIA_USE_FLISP_PARSER", false) === false
Base.JuliaSyntax.enable_in_core!()
end
include(joinpath(@__DIR__, "abi_export.jl"))
# Load user code
import Base.Experimental.entrypoint
# for use as C main if needed
function _main(argc::Cint, argv::Ptr{Ptr{Cchar}})::Cint
args = ccall(:jl_set_... | @@ -27,6 +27,62 @@ if Base.JLOptions().trim != 0
include(joinpath(@__DIR__, "juliac-trim-base.jl"))
end
+const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
+ Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
+ Cvoid, C... | contrib/juliac/juliac-buildscript.jl | 26 | Julia | 1 | suggestion | 632 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | topolarity | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-buildscript.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: task.rngState4 = 0x5502376d099035ae
uuid_tuple = (UInt64(0), UInt64(0))
ccall(:jl_set_module_uuid, Cvoid, (Any, NTuple{2, UInt64}), Base.__toplevel__, u... | ```suggestion
while T <: Ptr
T = T.parameters[1] # unwrap Ptr{...}
end
if T.name.module === Core && T ∉ C_friendly_types
error("invalid type for juliac: ", T) # exclude internals (they may change)
end
push!(types, T)
```
Mostly just to make the logic more direct, but there... | 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 MyTwoVec
x::Int32
y::Int32
end
Base.@ccallable "copyto_and_sum" function badname(fromto::CVectorPair{Float32})::Float32
from, to = unsafe_wrap(Array, fromto.from.data, fromto.from.length), unsafe_wrap(Array, fromto.to.data, fromto.to.length)
copyto!(to, from)
return sum(to)
end
Base.@ccalla... | Two slightly advanced (but important) features:
- `Ref{...}` should be supported in addition to `Ptr{...}`
- function pointers are just `Ptr{Cvoid}` ABI-wise but for C to be able to call them, we do need to export type definitions for them | struct MyTwoVec
x::Int32
y::Int32
end
struct CTree{T}
# test that recursive datatypes work as expected
children::CVector{CTree{T}}
end
Base.@ccallable "tree_size" function size(tree::CTree{Float64})::Int64
children = unsafe_wrap(Array, tree.children.data, tree.children.length)
# Return the siz... | @@ -0,0 +1,44 @@
+module SimpleLib
+# Test the logging of entrypoints and types in a C-callable Julia library.
+
+struct CVector{T}
+ length::Cint
+ data::Ptr{T}
+end
+
+struct CVectorPair{T}
+ from::CVector{T}
+ to::CVector{T}
+end
+
+struct MyTwoVec
+ x::Int32
+ y::Int32
+end
+
+Base.@ccallable "cop... | test/trimming/libsimple.jl | 26 | Julia | 0.786 | suggestion | 245 | 32 | 46 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | topolarity | timholy | Review this pull request change.
Language: Julia
File: test/trimming/libsimple.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: struct MyTwoVec
x::Int32
y::Int32
end
Base.@ccallable "copyto_and_sum" function badname(fromto::CVectorPair{Float32})::Float32
from, to = unsafe_wrap... | Two slightly advanced (but important) features:
- `Ref{...}` should be supported in addition to `Ptr{...}`
- function pointers are just `Ptr{Cvoid}` ABI-wise but for C to be able to call them, we do need to export type definitions for them | 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, symbol) = let
symbol = length(method.ccallable) > 2 ? Symbol(method.ccallable[3]) : method.name
iob = IOBuffer()
print(IOContext(iob, :print_method_signature_only => true), method)
str = String(take!(iob))
if symbol !== method.name && startswith(str, String(method.name... | Should this be `typeid` or `type_id` instead of just `type`? I don't feel strongly about this, but I suspect it might be clearer that it's a reference within the json file. | function emit_method_info!(ctx::TypeEmitter, method::Core.Method; indent::Int = 0)
(rt, sig) = method.ccallable
(name, symbol) = let
symbol = length(method.ccallable) > 2 ? Symbol(method.ccallable[3]) : method.name
iob = IOBuffer()
print(IOContext(iob, :print_method_signature_only => tru... | @@ -0,0 +1,219 @@
+const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
+ Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
+ Cvoid, Cint, Cshort, Clong, Cuint, Cushort, Culong, Cssize_t, Csize_t,
+ Cchar, Cwchar_t, Cstring, ... | contrib/juliac/abi_export.jl | 26 | Julia | 0.714 | suggestion | 172 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | timholy | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/abi_export.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: (name, symbol) = let
symbol = length(method.ccallable) > 2 ? Symbol(method.ccallable[3]) : method.name
iob = IOBuffer()
print(IOCont... | Should this be `typeid` or `type_id` instead of just `type`? I don't feel strongly about this, but I suspect it might be clearer that it's a reference within the json 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. |
end
function emit_method_info!(ctx::TypeEmitter, method::Core.Method; indent::Int = 0)
(rt, sig) = method.ccallable
(name, symbol) = let
symbol = length(method.ccallable) > 2 ? Symbol(method.ccallable[3]) : method.name
iob = IOBuffer()
print(IOContext(iob, :print_method_signature_only =... | Maybe call this `julia_signature` instead of `name`? The latter seems too generic. | emit_struct_info!(ctx, dt; indent)
end
end
function emit_method_info!(ctx::TypeEmitter, method::Core.Method; indent::Int = 0)
(rt, sig) = method.ccallable
(name, symbol) = let
symbol = length(method.ccallable) > 2 ? Symbol(method.ccallable[3]) : method.name
iob = IOBuffer()
... | @@ -0,0 +1,219 @@
+const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
+ Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
+ Cvoid, Cint, Cshort, Clong, Cuint, Cushort, Culong, Cssize_t, Csize_t,
+ Cchar, Cwchar_t, Cstring, ... | contrib/juliac/abi_export.jl | 26 | Julia | 0.429 | suggestion | 82 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | timholy | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/abi_export.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: end
function emit_method_info!(ctx::TypeEmitter, method::Core.Method; indent::Int = 0)
(rt, sig) = method.ccallable
(name, symbol) = let
symbol... | Maybe call this `julia_signature` instead of `name`? The latter seems too generic. | 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 escape_string_json(name)
end
function emit_pointer_info!(ctx::TypeEmitter, @nospecialize(dt::DataType); indent::Int = 0)
pointee_type_id = ctx.type_ids[dt.parameters[1]]
let indented_println(args...) = println(ctx.io, " " ^ indent, args...)
indented_println("{")
indented_println(" \... | Can you add `Base.isfieldatomic` as an optional field | return escape_string_json(name)
end
function emit_pointer_info!(ctx::TypeEmitter, @nospecialize(dt::DataType); indent::Int = 0)
pointee_type_id = ctx.type_ids[dt.parameters[1]]
let indented_println(args...) = println(ctx.io, " " ^ indent, args...)
indented_println("{")
indented_println(" \... | @@ -0,0 +1,219 @@
+const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
+ Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
+ Cvoid, Cint, Cshort, Clong, Cuint, Cushort, Culong, Cssize_t, Csize_t,
+ Cchar, Cwchar_t, Cstring, ... | contrib/juliac/abi_export.jl | 26 | Julia | 0.357 | suggestion | 53 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | vtjnash | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/abi_export.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: return escape_string_json(name)
end
function emit_pointer_info!(ctx::TypeEmitter, @nospecialize(dt::DataType); indent::Int = 0)
pointee_type_id = ctx.t... | Can you add `Base.isfieldatomic` as an optional field | 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. |
indented_println("{")
indented_println(" \"id\": ", ctx.type_ids[dt], ",")
indented_println(" \"kind\": \"pointer\",")
indented_println(" \"name\": ", type_name_json(dt), ",")
indented_println(" \"pointee_type_id\": ", pointee_type_id)
print(ctx.io, " " ^ indent, "}")... | ```suggestion
indented_println(ismutabletype(dt) ?(" \"kind\": \"mutable struct\",") : " \"kind\": \"struct\",")
``` | indented_println("{")
indented_println(" \"id\": ", ctx.type_ids[dt], ",")
indented_println(" \"kind\": \"pointer\",")
indented_println(" \"name\": ", type_name_json(dt), ",")
indented_println(" \"pointee_type_id\": ", pointee_type_id)
print(ctx.io, " " ^ indent, "}")... | @@ -0,0 +1,219 @@
+const C_friendly_types = Base.IdSet{Any}([ # a few of these are redundant to make it easier to maintain
+ Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Bool,
+ Cvoid, Cint, Cshort, Clong, Cuint, Cushort, Culong, Cssize_t, Csize_t,
+ Cchar, Cwchar_t, Cstring, ... | contrib/juliac/abi_export.jl | 26 | Julia | 0.857 | suggestion | 128 | 51 | 51 | false | juliac: log entrypoints and nonstandard typedefs | 59,108 | JuliaLang/julia | 35,573 | Julia | vtjnash | timholy | Review this pull request change.
Language: Julia
File: contrib/juliac/abi_export.jl
PR Title: juliac: log entrypoints and nonstandard typedefs
BEFORE CODE: indented_println("{")
indented_println(" \"id\": ", ctx.type_ids[dt], ",")
indented_println(" \"kind\": \"pointer\",")
indente... | ```suggestion
indented_println(ismutabletype(dt) ?(" \"kind\": \"mutable struct\",") : " \"kind\": \"struct\",")
``` | 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_throws exception expr
Tests that the expression `expr` throws `exception`.
The exception may specify either a type,
a string, regular expression, or list of strings occurring in the displayed error message,
a matching function,
or ... | Typo?
```suggestion
The three-argument form `@test_throws extype pattern expr` requires Julia v1.13 or later.
``` | #-----------------------------------------------------------------------
"""
@test_throws exception expr
@test_throws extype pattern expr
Tests that the expression `expr` throws `exception`.
The exception may specify either a type,
a string, regular expression, or list of strings occurring in the displayed er... | @@ -799,17 +799,29 @@ end
"""
@test_throws exception expr
+ @test_throws extype pattern expr
Tests that the expression `expr` throws `exception`.
The exception may specify either a type,
a string, regular expression, or list of strings occurring in the displayed error message,
a matching function,
or ... | stdlib/Test/src/Test.jl | 26 | Julia | 0.857 | suggestion | 117 | 51 | 51 | false | Test: `@test_throws` add 3-arg form for testing exception type and message | 59,117 | JuliaLang/julia | 35,573 | Julia | christiangnrd | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/Test/src/Test.jl
PR Title: Test: `@test_throws` add 3-arg form for testing exception type and message
BEFORE CODE: #-----------------------------------------------------------------------
"""
@test_throws exception expr
Tests that the expression `e... | Typo?
```suggestion
The three-argument form `@test_throws extype pattern expr` requires Julia v1.13 or later.
``` | 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. |
# Get file list from ARGS if provided, otherwise use git ls-files
errors = Set{Tuple{String,Int,String}}()
files_to_check = filter(arg -> arg != "--fix", ARGS)
if isempty(files_to_check)
files_to_check = eachline(`git ls-files -- $patterns`)
end
files_fixed = 0
for path in files_to_... | Ok, but a little bit assymetric with the case below. Would prefer to keep. | errors = Set{Tuple{String,Int,String}}()
files_to_check = filter(arg -> arg != "--fix", ARGS)
if isempty(files_to_check)
files_to_check = eachline(`git ls-files -- $patterns`)
end
files_fixed = 0
if "--fix" in ARGS
for path in files_to_check
content = newcontent = re... | @@ -59,7 +87,6 @@ function check_whitespace()
if isempty(errors)
println(stderr, "Whitespace check found no issues.")
- exit(0) | contrib/check-whitespace.jl | 26 | Julia | 0.286 | suggestion | 74 | 51 | 51 | false | build: add --fix option for check-whitespace | 59,118 | JuliaLang/julia | 35,573 | Julia | Keno | vtjnash | Review this pull request change.
Language: Julia
File: contrib/check-whitespace.jl
PR Title: build: add --fix option for check-whitespace
BEFORE CODE: # Get file list from ARGS if provided, otherwise use git ls-files
errors = Set{Tuple{String,Int,String}}()
files_to_check = filter(arg -> arg != "--fix",... | Ok, but a little bit assymetric with the case below. Would prefer to keep. | 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 indirect_deps
end
# this loop must be run after the full direct_deps map has been populated
indirect_deps = expand_indirect_dependencies(direct_deps)
for ext in keys(ext_to_parent)
ext_loadable_in_pkg = Dict{Base.PkgId,Bool}()
for pkg in keys(direct_deps)
is_t... | SGTM
```suggestion
if _from_loading
``` | return indirect_deps
end
# this loop must be run after the full direct_deps map has been populated
indirect_deps = expand_indirect_dependencies(direct_deps)
for ext in keys(ext_to_parent)
ext_loadable_in_pkg = Dict{Base.PkgId,Bool}()
for pkg in keys(direct_deps)
is_t... | @@ -630,15 +649,28 @@ function _precompilepkgs(pkgs::Vector{String},
end
@debug "precompile: extensions collected"
+ serial_deps = Base.PkgId[] # packages that are being precompiled in serial
+
+ if _from_loading && !isempty(requested_pkgs) | base/precompilation.jl | 26 | Julia | 0.429 | suggestion | 46 | 51 | 51 | false | Precompile out of env deps in serial within precompilepkgs | 59,122 | JuliaLang/julia | 35,573 | Julia | vtjnash | IanButterworth | Review this pull request change.
Language: Julia
File: base/precompilation.jl
PR Title: Precompile out of env deps in serial within precompilepkgs
BEFORE CODE: return indirect_deps
end
# this loop must be run after the full direct_deps map has been populated
indirect_deps = expand_indirect_depe... | SGTM
```suggestion
if _from_loading
``` | 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. |
# restrict to dependencies of given packages
function collect_all_deps(direct_deps, dep, alldeps=Set{Base.PkgId}())
for _dep in direct_deps[dep]
if !(_dep in alldeps)
push!(alldeps, _dep)
collect_all_deps(direct_deps, _dep, alldeps)
end
end
return alldeps
end
funct... | String interpolation is strongly frowned upon since it has terrible formatting and performance
```suggestion
@debug "precompilepkgs called with" pkgs internal_call strict warn_loaded timing _from_loading configs fancyprint manifest ignore_loaded
``` |
# restrict to dependencies of given packages
function collect_all_deps(direct_deps, dep, alldeps=Set{Base.PkgId}())
for _dep in direct_deps[dep]
if !(_dep in alldeps)
push!(alldeps, _dep)
collect_all_deps(direct_deps, _dep, alldeps)
end
end
return alldeps
end
funct... | @@ -468,6 +483,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
fancyprint::Bool = can_fancyprint(io) && !timing,
manifest::Bool=false,
ignore_loaded::Bool=true)
+ @debug "precompilepkgs called with: pkgs=$(pkgs), internal_call=$(i... | base/precompilation.jl | 26 | Julia | 0.929 | bug | 256 | 51 | 51 | false | Precompile out of env deps in serial within precompilepkgs | 59,122 | JuliaLang/julia | 35,573 | Julia | vtjnash | IanButterworth | Review this pull request change.
Language: Julia
File: base/precompilation.jl
PR Title: Precompile out of env deps in serial within precompilepkgs
BEFORE CODE:
# restrict to dependencies of given packages
function collect_all_deps(direct_deps, dep, alldeps=Set{Base.PkgId}())
for _dep in direct_deps[dep]
... | String interpolation is strongly frowned upon since it has terrible formatting and performance
```suggestion
@debug "precompilepkgs called with" pkgs internal_call strict warn_loaded timing _from_loading configs fancyprint manifest ignore_loaded
``` | 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. |
# `COMPLETION_WORLD[]` will be initialized within `__init__`
# (to allow us to potentially remove REPL from the sysimage in the future).
# Note that inference from the `code_typed` call below will use the current world age
# rather than `typemax(UInt)`, since `Base.invoke_in_world` uses the current world age
# when the... | The special-casing of the `do` block makes me slightly nervous and I wonder if a more general solution would be possible (at the juliacon hackathon you mentioned the option of reading just up to position for the purpose of completion, but that also has drawbacks), but I could confirm this fixes the issue (as confirmed ... | # `COMPLETION_WORLD[]` will be initialized within `__init__`
# (to allow us to potentially remove REPL from the sysimage in the future).
# Note that inference from the `code_typed` call below will use the current world age
# rather than `typemax(UInt)`, since `Base.invoke_in_world` uses the current world age
# when the... | @@ -692,6 +692,15 @@ code_typed(CC.typeinf, (REPLInterpreter, CC.InferenceState))
MAX_METHOD_COMPLETIONS::Int = 40
function _complete_methods(ex_org::Expr, context_module::Module, shift::Bool)
isempty(ex_org.args) && return 2, nothing, [], Set{Symbol}()
+ # Desugar do block call into call with lambda
+ if ... | stdlib/REPL/src/REPLCompletions.jl | 26 | Julia | 0.643 | suggestion | 366 | 51 | 51 | false | [REPL] Fix keyword arguments completions with do block | 59,123 | JuliaLang/julia | 35,573 | Julia | giordano | xal-0 | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/REPLCompletions.jl
PR Title: [REPL] Fix keyword arguments completions with do block
BEFORE CODE: # `COMPLETION_WORLD[]` will be initialized within `__init__`
# (to allow us to potentially remove REPL from the sysimage in the future).
# Note that... | The special-casing of the `do` block makes me slightly nervous and I wonder if a more general solution would be possible (at the juliacon hackathon you mentioned the option of reading just up to position for the purpose of completion, but that also has drawbacks), but I could confirm this fixes the issue (as confirmed ... | 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. |
and in the false branch, it will be limited by `cnd.elsetype`.
Example:
```julia
let cond = isa(x::Union{Int, Float}, Int)::Conditional(x, Int, Float)
if cond
# May assume x is `Int` now
else
# May assume x is `Float` now
end
end
```
"""
struct Conditional
slot::Int
thentype
elsety... | Technically this is required to be a LimitedAccuracy(Bool) to prevent caching the bad result (same everywhere in this PR) | and in the false branch, it will be limited by `cnd.elsetype`.
Example:
```julia
let cond = isa(x::Union{Int, Float}, Int)::Conditional(x, Int, Float)
if cond
# May assume x is `Int` now
else
# May assume x is `Float` now
end
end
```
"""
struct Conditional
slot::Int
thentype
elsety... | @@ -40,6 +40,9 @@ struct Conditional
isdefined::Bool=false)
assert_nested_slotwrapper(thentype)
assert_nested_slotwrapper(elsetype)
+ if thentype isa LimitedAccuracy || elsetype isa LimitedAccuracy
+ return Bool | Compiler/src/typelattice.jl | 26 | Julia | 0.357 | suggestion | 121 | 51 | 51 | false | inference: avoid `LimitedAccuracy` within slot wrappers | 59,182 | JuliaLang/julia | 35,573 | Julia | vtjnash | aviatesk | Review this pull request change.
Language: Julia
File: Compiler/src/typelattice.jl
PR Title: inference: avoid `LimitedAccuracy` within slot wrappers
BEFORE CODE: and in the false branch, it will be limited by `cnd.elsetype`.
Example:
```julia
let cond = isa(x::Union{Int, Float}, Int)::Conditional(x, Int, Float)
... | Technically this is required to be a LimitedAccuracy(Bool) to prevent caching the bad result (same everywhere in this PR) | 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. |
load_le_array(UInt64, arr, firstidx + pos + 8) ⊻ seed
)
if i > 32
seed = hash_mix(
load_le_array(UInt64, arr, firstidx + pos + 16) ⊻ secret[3],
load_le_array(UInt64, arr, firstidx + pos + 24) ⊻ seed
)
... | ```suggestion
shift_bits = (shift_bytes * 8) & 63
```
looks like it helps a little bit, a la https://github.com/JuliaLang/julia/issues/30674
on a length-10 generator I see like 12ns vs 10ns | load_le_array(UInt64, arr, firstidx + pos + 8) ⊻ seed
)
if i > 32
seed = hash_mix(
load_le_array(UInt64, arr, firstidx + pos + 16) ⊻ secret[3],
load_le_array(UInt64, arr, firstidx + pos + 24) ⊻ seed
)
... | @@ -344,6 +344,293 @@ load_le(::Type{T}, ptr::Ptr{UInt8}, i) where {T <: Union{UInt32, UInt64}} =
return hash_mix(a ⊻ secret[4], b ⊻ secret[2] ⊻ i)
end
+@inline function load_le_array(::Type{UInt64}, arr::AbstractArray{UInt8}, idx)
+ # n.b. for whatever reason, writing this as a loop ensures LLVM
+ # opti... | base/hashing.jl | 26 | Julia | 0.786 | suggestion | 201 | 51 | 51 | false | add safer, more versatile version of rapidhash for any array and for any iterable | 59,185 | JuliaLang/julia | 35,573 | Julia | adienes | vtjnash | Review this pull request change.
Language: Julia
File: base/hashing.jl
PR Title: add safer, more versatile version of rapidhash for any array and for any iterable
BEFORE CODE: load_le_array(UInt64, arr, firstidx + pos + 8) ⊻ seed
)
if i > 32
seed = hash_mix(
... | ```suggestion
shift_bits = (shift_bytes * 8) & 63
```
looks like it helps a little bit, a la https://github.com/JuliaLang/julia/issues/30674
on a length-10 generator I see like 12ns vs 10ns | 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. |
see1 = seed
see2 = seed
l0 = zero(UInt64)
l1 = zero(UInt64)
l2 = zero(UInt64)
l3 = zero(UInt64)
l4 = zero(UInt64)
l5 = zero(UInt64)
b0 = 0
b1 = 0
b2 = 0
b3 = 0
b4 = 0
b5 = 0
t0 = zero(UInt64)
t1 = zero(UInt64)
# Handle first iteration separately
... | Making these >= might give an even faster result then? It was slightly annoying to come up with a form for this that was not too repetitive but fairly good, and llvm seemed confused that b1<=8 from the previous loop, so it doesn't jump thread it right | t1 = zero(UInt64)
# Handle first iteration separately
read = read_uint64_from_uint8_iter(iter)
if read !== nothing
l0, state, b0 = read
# Repeat hashing chunks until a short read
while true
l1, state, b1 = read_uint64_from_uint8_iter(iter, state)
if b1 ==... | @@ -344,6 +344,293 @@ load_le(::Type{T}, ptr::Ptr{UInt8}, i) where {T <: Union{UInt32, UInt64}} =
return hash_mix(a ⊻ secret[4], b ⊻ secret[2] ⊻ i)
end
+@inline function load_le_array(::Type{UInt64}, arr::AbstractArray{UInt8}, idx)
+ # n.b. for whatever reason, writing this as a loop ensures LLVM
+ # opti... | base/hashing.jl | 26 | Julia | 0.643 | suggestion | 251 | 51 | 51 | false | add safer, more versatile version of rapidhash for any array and for any iterable | 59,185 | JuliaLang/julia | 35,573 | Julia | vtjnash | vtjnash | Review this pull request change.
Language: Julia
File: base/hashing.jl
PR Title: add safer, more versatile version of rapidhash for any array and for any iterable
BEFORE CODE:
see1 = seed
see2 = seed
l0 = zero(UInt64)
l1 = zero(UInt64)
l2 = zero(UInt64)
l3 = zero(UInt64)
l4 = zero(UInt6... | Making these >= might give an even faster result then? It was slightly annoying to come up with a form for this that was not too repetitive but fairly good, and llvm seemed confused that b1<=8 from the previous loop, so it doesn't jump thread it 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. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
#####################
# structs/constants #
#####################
# N.B.: Const/PartialStruct/InterConditional are defined in Core, to allow them to be used
# inside the global code cache.
import Core: Const, InterConditional, PartialStruct... | Lgtm. As a followup improvement, note that this actually should be intersect for more accuracy, which we could implement by changing causes to a number (the frame/cycle id) and use min/max on that | # This file is a part of Julia. License is MIT: https://julialang.org/license
#####################
# structs/constants #
#####################
# N.B.: Const/PartialStruct/InterConditional are defined in Core, to allow them to be used
# inside the global code cache.
import Core: Const, InterConditional, PartialStruct... | @@ -8,6 +8,19 @@
# inside the global code cache.
import Core: Const, InterConditional, PartialStruct
+function may_form_limited_typ(@nospecialize(aty), @nospecialize(bty), @nospecialize(xty))
+ if aty isa LimitedAccuracy
+ if bty isa LimitedAccuracy
+ return LimitedAccuracy(xty, union!(copy(aty... | Compiler/src/typelattice.jl | 14 | Julia | 0.429 | suggestion | 196 | 39 | 39 | false | inference: propagate more `LimitedAccuracy` information | 59,187 | JuliaLang/julia | 35,573 | Julia | vtjnash | aviatesk | Review this pull request change.
Language: Julia
File: Compiler/src/typelattice.jl
PR Title: inference: propagate more `LimitedAccuracy` information
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
#####################
# structs/constants #
#####################
# N.B.: ... | Lgtm. As a followup improvement, note that this actually should be intersect for more accuracy, which we could implement by changing causes to a number (the frame/cycle id) and use min/max on that | 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 nth(cycle_size_unknown, 20) == 9 # mod1(20, 5) = 5, wraps 4 times
@test nth(finite_cycle_size_unknown, 2) == 3
@test nth(finite_cycle_size_unknown, 20) == 9
@test_throws BoundsError nth(finite_cycle_size_unknown, 30) # only wraps 5 times, max n is 5 * 5 = 25
end
@testset "Iterators docstrings" be... | ```
isdefined(Main, :OffsetArrays) || @eval Main include("testhelpers/OffsetArrays.jl")
using .Main.OffsetArrays
```
is a pattern used in many test suites to get `OffsetArrays` in Base tests (put at the top | cycle_size_unknown = Iterators.cycle(it_size_unknown)
finite_cycle_size_unknown = Iterators.cycle(it_size_unknown, 5)
@test nth(cycle_size_unknown, 2) == 3
@test nth(cycle_size_unknown, 20) == 9 # mod1(20, 5) = 5, wraps 4 times
@test nth(finite_cycle_size_unknown, 2) == 3
@test nth(finite_cycle_... | @@ -1206,3 +1204,18 @@ end
@test Base.infer_return_type((Vector{Any},)) do xs
[x for x in xs if x isa Int]
end == Vector{Int}
+
+@testset "issue #58922" begin
+ # `last` short circuits correctly
+ @test last(zip(1:10, 2:11)) == (10, 11) # same length
+ @test last(zip(1:3, 2:11)) == (3, 4) # differe... | test/iterators.jl | 26 | Julia | 0.857 | refactor | 212 | 30 | 41 | false | Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types | 59,217 | JuliaLang/julia | 35,573 | Julia | adienes | jakewilliami | Review this pull request change.
Language: Julia
File: test/iterators.jl
PR Title: Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types
BEFORE CODE: @test nth(cycle_size_unknown, 20) == 9 # mod1(20, 5) = 5, wraps 4 times
@test nth(finite_cycle_size_unknown, 2) == 3
@test nth(f... | ```
isdefined(Main, :OffsetArrays) || @eval Main include("testhelpers/OffsetArrays.jl")
using .Main.OffsetArrays
```
is a pattern used in many test suites to get `OffsetArrays` in Base tests (put at the top | 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. |
# Flatten{Take{Repeated{O}}} is the actual type of an Iterators.cycle(iterable::O, m) iterator
function _nth(::Union{HasShape, HasLength}, itr::Flatten{Take{Repeated{O}}}, n::Integer) where {O}
cycles = itr.it.n
torepeat = itr.it.xs.x
k = length(torepeat)
(n > k*cycles || k == 0) && throw(BoundsError(i... | ```suggestion
_nth(::Union{HasShape, HasLength}, z::Zip, n::Integer) = Base.map(nth(n), z.is)
``` |
# Flatten{Take{Repeated{O}}} is the actual type of an Iterators.cycle(iterable::O, m) iterator
function _nth(::Union{HasShape, HasLength}, itr::Flatten{Take{Repeated{O}}}, n::Integer) where {O}
cycles = itr.it.n
torepeat = itr.it.xs.x
k = length(torepeat)
(n > k*cycles || k == 0) && throw(BoundsError(i... | @@ -1700,6 +1701,10 @@ function _nth(::IteratorSize, itr, n::Integer)
y === nothing && throw(BoundsError(itr, n))
y[1]
end
+
+# issue #58922
+_nth(::Union{HasShape, HasLength}, z::Zip, n::Integer) = map(nth(n), z.is) | base/iterators.jl | 26 | Julia | 0.571 | suggestion | 99 | 50 | 49 | false | Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types | 59,217 | JuliaLang/julia | 35,573 | Julia | adienes | jakewilliami | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types
BEFORE CODE:
# Flatten{Take{Repeated{O}}} is the actual type of an Iterators.cycle(iterable::O, m) iterator
function _nth(::Union{HasShape, HasLength}, ... | ```suggestion
_nth(::Union{HasShape, HasLength}, z::Zip, n::Integer) = Base.map(nth(n), z.is)
``` | 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
# Flatten{Take{Repeated{O}}} is the actual type of an Iterators.cycle(iterable::O, m) iterator
function _nth(::Union{HasShape, HasLength}, itr::Flatten{Take{Repeated{O}}}, n::Integer) where {O}
cycles = itr.it.n
torepeat = itr.it.xs.x
k = length(torepeat)
(n > k*cycles || k == 0) && throw(BoundsErr... | ```suggestion
```
this specialization is reasonable to add no matter the motivating issue :) | end
# Flatten{Take{Repeated{O}}} is the actual type of an Iterators.cycle(iterable::O, m) iterator
function _nth(::Union{HasShape, HasLength}, itr::Flatten{Take{Repeated{O}}}, n::Integer) where {O}
cycles = itr.it.n
torepeat = itr.it.xs.x
k = length(torepeat)
(n > k*cycles || k == 0) && throw(BoundsErr... | @@ -1700,6 +1701,10 @@ function _nth(::IteratorSize, itr, n::Integer)
y === nothing && throw(BoundsError(itr, n))
y[1]
end
+
+# issue #58922 | base/iterators.jl | 26 | Julia | 0.571 | suggestion | 96 | 51 | 50 | false | Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types | 59,217 | JuliaLang/julia | 35,573 | Julia | adienes | jakewilliami | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types
BEFORE CODE: end
# Flatten{Take{Repeated{O}}} is the actual type of an Iterators.cycle(iterable::O, m) iterator
function _nth(::Union{HasShape, HasLengt... | ```suggestion
```
this specialization is reasonable to add no matter the motivating 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. |
d = isdone(is[1], ss[1]...)
d´, ds = _zip_isdone(tail(is), tail(ss))
return (d === true || d´, (d, ds...))
end
_zip_isdone(::Tuple{}, ::Tuple{}) = (false, ())
IteratorSize(::Type{Zip{Is}}) where {Is<:Tuple} = zip_iteratorsize(ntuple(n -> IteratorSize(fieldtype(Is, n)), _counttuple(Is)::Int)...)
IteratorElt... | Changing
`getindex.(z.is, minimum(Base.map(lastindex, z.is)))`
to
`nth(z, length(z))`
is a clear win and an easy merge. Thanks! | d = isdone(is[1], ss[1]...)
d´, ds = _zip_isdone(tail(is), tail(ss))
return (d === true || d´, (d, ds...))
end
_zip_isdone(::Tuple{}, ::Tuple{}) = (false, ())
IteratorSize(::Type{Zip{Is}}) where {Is<:Tuple} = zip_iteratorsize(ntuple(n -> IteratorSize(fieldtype(Is, n)), _counttuple(Is)::Int)...)
IteratorElt... | @@ -473,7 +473,12 @@ zip_iteratoreltype() = HasEltype()
zip_iteratoreltype(a) = a
zip_iteratoreltype(a, tail...) = and_iteratoreltype(a, zip_iteratoreltype(tail...))
-last(z::Zip) = getindex.(z.is, minimum(Base.map(lastindex, z.is)))
+function last(z::Zip)
+ IteratorSize(z) == SizeUnknown() &&
+ throw(Arg... | base/iterators.jl | 26 | Julia | 0.5 | suggestion | 132 | 51 | 51 | false | Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types | 59,217 | JuliaLang/julia | 35,573 | Julia | LilithHafner | jakewilliami | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types
BEFORE CODE: d = isdone(is[1], ss[1]...)
d´, ds = _zip_isdone(tail(is), tail(ss))
return (d === true || d´, (d, ds...))
end
_zip_isdone(::Tup... | Changing
`getindex.(z.is, minimum(Base.map(lastindex, z.is)))`
to
`nth(z, length(z))`
is a clear win and an easy merge. Thanks! | 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 _zip_isdone(is, ss)
d = isdone(is[1], ss[1]...)
d´, ds = _zip_isdone(tail(is), tail(ss))
return (d === true || d´, (d, ds...))
end
_zip_isdone(::Tuple{}, ::Tuple{}) = (false, ())
IteratorSize(::Type{Zip{Is}}) where {Is<:Tuple} = zip_iteratorsize(ntuple(n -> IteratorSize(fieldtype(Is, n)), _counttu... | This is breaking. It might be only slightly breaking but even then it would need to be well justified. (`SizeUnknown` does not guarantee that length will throw) | function _zip_isdone(is, ss)
d = isdone(is[1], ss[1]...)
d´, ds = _zip_isdone(tail(is), tail(ss))
return (d === true || d´, (d, ds...))
end
_zip_isdone(::Tuple{}, ::Tuple{}) = (false, ())
IteratorSize(::Type{Zip{Is}}) where {Is<:Tuple} = zip_iteratorsize(ntuple(n -> IteratorSize(fieldtype(Is, n)), _counttu... | @@ -473,7 +473,12 @@ zip_iteratoreltype() = HasEltype()
zip_iteratoreltype(a) = a
zip_iteratoreltype(a, tail...) = and_iteratoreltype(a, zip_iteratoreltype(tail...))
-last(z::Zip) = getindex.(z.is, minimum(Base.map(lastindex, z.is)))
+function last(z::Zip)
+ IteratorSize(z) == SizeUnknown() &&
+ throw(Arg... | base/iterators.jl | 26 | Julia | 0.5 | suggestion | 160 | 51 | 51 | false | Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types | 59,217 | JuliaLang/julia | 35,573 | Julia | LilithHafner | jakewilliami | Review this pull request change.
Language: Julia
File: base/iterators.jl
PR Title: Fix inconsistent behaviour for `last(::Zip)` with differing iterator size types
BEFORE CODE: function _zip_isdone(is, ss)
d = isdone(is[1], ss[1]...)
d´, ds = _zip_isdone(tail(is), tail(ss))
return (d === true || d´, (d, ... | This is breaking. It might be only slightly breaking but even then it would need to be well justified. (`SizeUnknown` does not guarantee that length will throw) | 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. |
// Get handle to sys.so
return jl_set_sysimg_so(jl_load_dynamic_library(fname, JL_RTLD_LOCAL | JL_RTLD_NOW, 1));
}
}
typedef void jl_image_unpack_func_t(void *handle, jl_image_buf_t *image);
JL_DLLEXPORT void jl_image_unpack_uncomp(void *handle, jl_image_buf_t *image)
{
size_t *plen;
jl_dl... | We probably want to mmap this with huge pages/large pages | return jl_sysimage_buf;
} else {
// Get handle to sys.so
return jl_set_sysimg_so(jl_load_dynamic_library(fname, JL_RTLD_LOCAL | JL_RTLD_NOW, 1));
}
}
typedef void jl_image_unpack_func_t(void *handle, jl_image_buf_t *image);
static void jl_prefetch_system_image(const char *data, size_t ... | @@ -3638,14 +3641,43 @@ JL_DLLEXPORT jl_image_buf_t jl_preload_sysimg(const char *fname)
}
}
-// From a shared library handle, verify consistency and return a jl_image_buf_t
-static jl_image_buf_t get_image_buf(void *handle, int is_pkgimage)
+typedef void jl_image_unpack_func_t(void *handle, jl_image_buf_t *ima... | src/staticdata.c | 26 | C | 0.214 | suggestion | 57 | 51 | 51 | false | System image compression with zstd | 59,227 | JuliaLang/julia | 35,573 | Julia | gbaraldi | xal-0 | Review this pull request change.
Language: C
File: src/staticdata.c
PR Title: System image compression with zstd
BEFORE CODE: // Get handle to sys.so
return jl_set_sysimg_so(jl_load_dynamic_library(fname, JL_RTLD_LOCAL | JL_RTLD_NOW, 1));
}
}
typedef void jl_image_unpack_func_t(void *handle, jl... | We probably want to mmap this with huge pages/large pages | 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_OPTIONS_USE_COMPILED_MODULES_YES,
JL_OPTIONS_USE_PKGIMAGES_YES,
NULL, // bind-to
NULL, // output-bc
NULL, // output-unopt-bc
NULL, // output-o
NULL, ... | We should revisit this default, but fine for now | JL_OPTIONS_USE_COMPILED_MODULES_YES,
JL_OPTIONS_USE_PKGIMAGES_YES,
NULL, // bind-to
NULL, // output-bc
NULL, // output-unopt-bc
NULL, // output-o
NULL, ... | @@ -160,6 +160,7 @@ JL_DLLEXPORT void jl_init_options(void)
0, // task_metrics
-1, // timeout_for_safepoint_straggler_s
0, // gc_sweep_always_full
+ 0, // compress_sysimage | src/jloptions.c | 26 | C | 0.143 | suggestion | 48 | 51 | 51 | false | System image compression with zstd | 59,227 | JuliaLang/julia | 35,573 | Julia | gbaraldi | xal-0 | Review this pull request change.
Language: C
File: src/jloptions.c
PR Title: System image compression with zstd
BEFORE CODE: JL_OPTIONS_USE_COMPILED_MODULES_YES,
JL_OPTIONS_USE_PKGIMAGES_YES,
NULL, // bind-to
NULL, // ou... | We should revisit this default, but fine for now | 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. |
# Issue #57696
# This test checks for invalidation of recursive backedges. However, unfortunately, the original failure
# manifestation was an unreliable segfault or an assertion failure, so we don't have a more compact test.
@test success(`$(Base.julia_cmd()) -e 'Base.typejoin(x, ::Type) = 0; exit()'`)
# Test drop_al... | Needs to test that there is a recompile | # Issue #57696
# This test checks for invalidation of recursive backedges. However, unfortunately, the original failure
# manifestation was an unreliable segfault or an assertion failure, so we don't have a more compact test.
@test success(`$(Base.julia_cmd()) -e 'Base.typejoin(x, ::Type) = 0; exit()'`)
# Test drop_al... | @@ -325,3 +325,26 @@ end
# This test checks for invalidation of recursive backedges. However, unfortunately, the original failure
# manifestation was an unreliable segfault or an assertion failure, so we don't have a more compact test.
@test success(`$(Base.julia_cmd()) -e 'Base.typejoin(x, ::Type) = 0; exit()'`)
+
... | Compiler/test/invalidation.jl | 26 | Julia | 0.071 | suggestion | 39 | 28 | 41 | false | Drop sysimage caches for --code-coverage=all | 59,234 | JuliaLang/julia | 35,573 | Julia | Keno | IanButterworth | Review this pull request change.
Language: Julia
File: Compiler/test/invalidation.jl
PR Title: Drop sysimage caches for --code-coverage=all
BEFORE CODE: # Issue #57696
# This test checks for invalidation of recursive backedges. However, unfortunately, the original failure
# manifestation was an unreliable segfault ... | Needs to test that there is a recompile | 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 (name == jl_nothing)
meth->ccallable = jl_svec2(declrt, (jl_value_t*)sigt);
else
meth->ccallable = jl_svec3(declrt, (jl_value_t*)sigt, name);
jl_gc_wb(meth, meth->ccallable);
JL_GC_POP();
}
// Drop all method caches and increment world age as if adding a method that intersects everyt... | I'd prefer this be written in julia | if (name == jl_nothing)
meth->ccallable = jl_svec2(declrt, (jl_value_t*)sigt);
else
meth->ccallable = jl_svec3(declrt, (jl_value_t*)sigt, name);
jl_gc_wb(meth, meth->ccallable);
JL_GC_POP();
}
// Drop all method caches and increment world age as if adding a method that intersects everyt... | @@ -5087,6 +5087,71 @@ JL_DLLEXPORT void jl_extern_c(jl_value_t *name, jl_value_t *declrt, jl_tupletype
JL_GC_POP();
}
+// Drop all method caches and increment world age as if adding a method that intersects everything
+static int invalidate_all_specializations(jl_typemap_entry_t *def, void *closure) | src/gf.c | 26 | C | 0.143 | suggestion | 35 | 51 | 51 | false | Drop sysimage caches for --code-coverage=all | 59,234 | JuliaLang/julia | 35,573 | Julia | Keno | IanButterworth | Review this pull request change.
Language: C
File: src/gf.c
PR Title: Drop sysimage caches for --code-coverage=all
BEFORE CODE: if (name == jl_nothing)
meth->ccallable = jl_svec2(declrt, (jl_value_t*)sigt);
else
meth->ccallable = jl_svec3(declrt, (jl_value_t*)sigt, name);
jl_gc_wb(meth, ... | I'd prefer this be written in julia | 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 if (specializations != NULL) {
jl_method_instance_t *mi = (jl_method_instance_t*)specializations;
invalidate_method_instance_caches(mi, world);
}
JL_UNLOCK(&method->writelock);
return 1;
}
static int invalidate_all_caches_visitor(jl_methtable_t *mt, void *env)
{
return jl... | There is only one method table now, so you can just examine it directly:
```suggestion
invalidate_all_caches_visitor(jl_method_table, current_world);
``` | }
else if (specializations != NULL) {
jl_method_instance_t *mi = (jl_method_instance_t*)specializations;
invalidate_method_instance_caches(mi, world);
}
JL_UNLOCK(&method->writelock);
return 1;
}
static int invalidate_all_caches_visitor(jl_methtable_t *mt, void *env)
{
return jl... | @@ -5087,6 +5087,69 @@ JL_DLLEXPORT void jl_extern_c(jl_value_t *name, jl_value_t *declrt, jl_tupletype
JL_GC_POP();
}
+// Drop all method caches and increment world age as if adding a method that intersects everything
+static void invalidate_method_instance_caches(jl_method_instance_t *mi, size_t world)
+{
+ ... | src/gf.c | 26 | C | 0.714 | performance | 160 | 39 | 35 | false | Drop sysimage caches for --code-coverage=all | 59,234 | JuliaLang/julia | 35,573 | Julia | vtjnash | IanButterworth | Review this pull request change.
Language: C
File: src/gf.c
PR Title: Drop sysimage caches for --code-coverage=all
BEFORE CODE: }
else if (specializations != NULL) {
jl_method_instance_t *mi = (jl_method_instance_t*)specializations;
invalidate_method_instance_caches(mi, world);
}
JL_... | There is only one method table now, so you can just examine it directly:
```suggestion
invalidate_all_caches_visitor(jl_method_table, current_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. |
full_path = try
ispath(path) || isempty(paths)
catch err
# access(2) errors unhandled by ispath: EACCES, EIO, ELOOP, ENAMETOOLONG
if err isa Base.IOError
false
elseif err isa Base.ArgumentError && occursin("embedded NULs", err.msg)
false
else
... | As you pointed out, this isn't needed since it is a pkgimage already | full_path = try
ispath(path) || isempty(paths)
catch err
# access(2) errors unhandled by ispath: EACCES, EIO, ELOOP, ENAMETOOLONG
if err isa Base.IOError
false
elseif err isa Base.ArgumentError && occursin("embedded NULs", err.msg)
false
else
... | @@ -1395,7 +1395,9 @@ function complete_path_string(path, hint::Bool=false;
end
function __init__()
- COMPLETION_WORLD[] = Base.get_world_counter()
+ if !Base.Compiler.should_insert_coverage(@__MODULE__, debuginfo) | stdlib/REPL/src/REPLCompletions.jl | 26 | Julia | 0.214 | suggestion | 68 | 33 | 31 | false | Drop sysimage caches for --code-coverage=all | 59,234 | JuliaLang/julia | 35,573 | Julia | vtjnash | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/REPLCompletions.jl
PR Title: Drop sysimage caches for --code-coverage=all
BEFORE CODE: full_path = try
ispath(path) || isempty(paths)
catch err
# access(2) errors unhandled by ispath: EACCES, EIO, ELOOP, ENAMETOOLONG
... | As you pointed out, this isn't needed since it is a pkgimage already | 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. |
catch err
# access(2) errors unhandled by ispath: EACCES, EIO, ELOOP, ENAMETOOLONG
if err isa Base.IOError
false
elseif err isa Base.ArgumentError && occursin("embedded NULs", err.msg)
false
else
rethrow()
end
end
expanded && !hint ... | ```suggestion
COMPLETION_WORLD[] = Base.get_world_counter()
```
| catch err
# access(2) errors unhandled by ispath: EACCES, EIO, ELOOP, ENAMETOOLONG
if err isa Base.IOError
false
elseif err isa Base.ArgumentError && occursin("embedded NULs", err.msg)
false
else
rethrow()
end
end
expanded && !hint ... | @@ -1395,7 +1395,9 @@ function complete_path_string(path, hint::Bool=false;
end
function __init__()
- COMPLETION_WORLD[] = Base.get_world_counter()
+ if !Base.Compiler.should_insert_coverage(@__MODULE__, debuginfo)
+ COMPLETION_WORLD[] = Base.get_world_counter()
+ end | stdlib/REPL/src/REPLCompletions.jl | 26 | Julia | 0.571 | suggestion | 68 | 31 | 29 | false | Drop sysimage caches for --code-coverage=all | 59,234 | JuliaLang/julia | 35,573 | Julia | IanButterworth | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/REPL/src/REPLCompletions.jl
PR Title: Drop sysimage caches for --code-coverage=all
BEFORE CODE: catch err
# access(2) errors unhandled by ispath: EACCES, EIO, ELOOP, ENAMETOOLONG
if err isa Base.IOError
false
elsei... | ```suggestion
COMPLETION_WORLD[] = Base.get_world_counter()
```
| 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. |
ERROR: ErrorException
"""s, err_str)
end
@testset "defining `ans` and `err`" begin
@test eval(:(ans = 1)) == 1
@test eval(:(err = 1)) == 1
end
@testset "scrub REPL-related frames" begin
repl_bt = [StackFrame(:foo, "foo.jl", 1),
StackFrame(:__repl_entry_anysuffix, "client.jl", 2),... | I don't understand this comment. `macro bad(); error(); end` with `errexpr = :(@bad)` should be enough. | ERROR: ErrorException
"""s, err_str)
end
@testset "defining `ans` and `err`" begin
@test eval(:(ans = 1)) == 1
@test eval(:(err = 1)) == 1
end
@testset "scrub REPL-related frames" begin
repl_bt = [StackFrame(:foo, "foo.jl", 1),
StackFrame(:__repl_entry_anysuffix, "client.jl", 2),... | @@ -57,3 +59,28 @@ end
@test eval(:(ans = 1)) == 1
@test eval(:(err = 1)) == 1
end
+
+@testset "scrub REPL-related frames" begin
+ repl_bt = [StackFrame(:foo, "foo.jl", 1),
+ StackFrame(:__repl_entry_anysuffix, "client.jl", 2),
+ StackFrame(:bar, "bar.jl", 3)]
+ scrubbed_repl_bt = Bas... | test/client.jl | 26 | Julia | 0.714 | suggestion | 103 | 34 | 40 | false | Restore stacktrace scrubing in fallback REPL. | 59,241 | JuliaLang/julia | 35,573 | Julia | Keno | BioTurboNick | Review this pull request change.
Language: Julia
File: test/client.jl
PR Title: Restore stacktrace scrubing in fallback REPL.
BEFORE CODE: ERROR: ErrorException
"""s, err_str)
end
@testset "defining `ans` and `err`" begin
@test eval(:(ans = 1)) == 1
@test eval(:(err = 1)) == 1
end
@testset... | I don't understand this comment. `macro bad(); error(); end` with `errexpr = :(@bad)` should be enough. | 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 sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
@test my_eq(sinpi(one(T)/convert(T,6)), 0.5)
@test my_eq(sincospi(one(T)/convert(T,6))[1], 0.5)
@test_throws DomainError sin... | ```suggestion
Base.Fix1(round, typ), Base.Fix1(trunc, typ), (+), ∘(-, -), ∘(-, cosc),
``` | @test sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
@test my_eq(sinpi(one(T)/convert(T,6)), 0.5)
@test my_eq(sincospi(one(T)/convert(T,6))[1], 0.5)
@test_throws DomainError sin... | @@ -590,6 +590,23 @@ end
@test ismissing(scdm[2])
end
+@testset "behavior at signed zero of monotonic floating-point functions mapping zero to zero" begin
+ @testset "typ: $typ" for typ in (Float16, Float32, Float64)
+ @testset "f: $f" for f in (
+ # all strictly increasing
+ ide... | test/math.jl | 26 | Julia | 0.714 | suggestion | 103 | 51 | 51 | false | test: math: test floating-point behavior when mapping zero to zero | 59,265 | JuliaLang/julia | 35,573 | Julia | stevengj | nsajko | Review this pull request change.
Language: Julia
File: test/math.jl
PR Title: test: math: test floating-point behavior when mapping zero to zero
BEFORE CODE: @test sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
... | ```suggestion
Base.Fix1(round, typ), Base.Fix1(trunc, typ), (+), ∘(-, -), ∘(-, cosc),
``` | 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. |
@testset let context=(T, has_fma[T], my_eq)
@test sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
@test my_eq(sinpi(one(T)/convert(T,6)), 0.5)
@test my_eq(sincospi(one(T)/convert(T,6... | ```suggestion
sin, sind, sinpi, tan, tand, tanpi, asin, asind, atan, atand, Base.Fix2(atan, one(typ)), Base.Fix2(atand, one(typ)),
``` | @testset let context=(T, has_fma[T], my_eq)
@test sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
@test my_eq(sinpi(one(T)/convert(T,6)), 0.5)
@test my_eq(sincospi(one(T)/convert(T,6... | @@ -590,6 +590,23 @@ end
@test ismissing(scdm[2])
end
+@testset "behavior at signed zero of monotonic floating-point functions mapping zero to zero" begin
+ @testset "typ: $typ" for typ in (Float16, Float32, Float64)
+ @testset "f: $f" for f in (
+ # all strictly increasing
+ ide... | test/math.jl | 26 | Julia | 0.714 | suggestion | 148 | 51 | 51 | false | test: math: test floating-point behavior when mapping zero to zero | 59,265 | JuliaLang/julia | 35,573 | Julia | stevengj | nsajko | Review this pull request change.
Language: Julia
File: test/math.jl
PR Title: test: math: test floating-point behavior when mapping zero to zero
BEFORE CODE: @testset let context=(T, has_fma[T], my_eq)
@test sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
... | ```suggestion
sin, sind, sinpi, tan, tand, tanpi, asin, asind, atan, atand, Base.Fix2(atan, one(typ)), Base.Fix2(atand, one(typ)),
``` | 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 sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
@test my_eq(sinpi(one(T)/convert(T,6)), 0.5)
@test my_eq(sincospi(one(T)/convert(T,6))[1], 0.5)
@test_throws DomainError sin... | Should other rounding modes be tested too? | @test sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
@test my_eq(sinpi(one(T)/convert(T,6)), 0.5)
@test my_eq(sincospi(one(T)/convert(T,6))[1], 0.5)
@test_throws DomainError sin... | @@ -590,6 +590,23 @@ end
@test ismissing(scdm[2])
end
+@testset "behavior at signed zero of monotonic floating-point functions mapping zero to zero" begin
+ @testset "typ: $typ" for typ in (Float16, Float32, Float64)
+ @testset "f: $f" for f in (
+ # all strictly increasing
+ ide... | test/math.jl | 26 | Julia | 0.143 | question | 42 | 51 | 51 | false | test: math: test floating-point behavior when mapping zero to zero | 59,265 | JuliaLang/julia | 35,573 | Julia | stevengj | nsajko | Review this pull request change.
Language: Julia
File: test/math.jl
PR Title: test: math: test floating-point behavior when mapping zero to zero
BEFORE CODE: @test sind(convert(T,30)) == 0.5
@test cosd(convert(T,60)) == 0.5
@test sind(convert(T,150)) == 0.5
... | Should other rounding modes be tested too? | 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. |
uv_mutex_lock(&tls_lock);
if (tid == -1)
tid = jl_atomic_load_relaxed(&jl_n_threads);
ptls->tid = tid;
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states);
if (jl_all_tls_states_size <= tid) {
int i, newsize = jl_all_tls_states_size + tid + 2;
jl_ptls_t *newpptl... | ```suggestion
void JL_NOTSAFEPOINT (*jl_unw_ensure_tls)(void) = NULL;
``` | ptls->tid = tid;
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states);
if (jl_all_tls_states_size <= tid) {
int i, newsize = jl_all_tls_states_size + tid + 2;
jl_ptls_t *newpptls = (jl_ptls_t*)calloc(newsize, sizeof(jl_ptls_t));
for (i = 0; i < jl_all_tls_states_size; i+... | @@ -403,7 +403,10 @@ jl_ptls_t jl_init_threadtls(int16_t tid)
#if !defined(_OS_WINDOWS_) && !defined(JL_DISABLE_LIBUNWIND) && !defined(LLVMLIBUNWIND)
// ensures libunwind TLS space for this thread is allocated eagerly
// to make unwinding async-signal-safe even when using thread local caches.
- unw_ensure... | src/threading.c | 26 | C | 0.714 | suggestion | 79 | 51 | 51 | false | Avoid depending on Julia-patched libunwind ABI | 59,266 | JuliaLang/julia | 35,573 | Julia | topolarity | gbaraldi | Review this pull request change.
Language: C
File: src/threading.c
PR Title: Avoid depending on Julia-patched libunwind ABI
BEFORE CODE: uv_mutex_lock(&tls_lock);
if (tid == -1)
tid = jl_atomic_load_relaxed(&jl_n_threads);
ptls->tid = tid;
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_al... | ```suggestion
void JL_NOTSAFEPOINT (*jl_unw_ensure_tls)(void) = NULL;
``` | 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 b1[] - b0[]
end
only(methods(allocated)).called = 0xff
@constprop :none function allocations(f, args::Vararg{Any,N}) where {N}
stats = Base.gc_num()
val = f(args...)
diff = Base.GC_Diff(Base.gc_num(), stats)
donotdelete(val)
return Base.gc_alloc_count(diff)
end
only(methods(allocations))... | My new doc string is not entirely consistent with this. We may want to remove this as it's kind of hard to explain. | end
only(methods(allocated)).called = 0xff
@constprop :none function allocations(f, args::Vararg{Any,N}) where {N}
stats = Base.gc_num()
@noinline f(args...)
diff = Base.GC_Diff(Base.gc_num(), stats)
return Base.gc_alloc_count(diff)
end
only(methods(allocations)).called = 0xff
function is_simply_call(... | @@ -501,12 +503,52 @@ function is_simply_call(@nospecialize ex)
return true
end
+function _gen_allocation_measurer(ex, fname::Symbol)
+ if isexpr(ex, :call)
+ if !is_simply_call(ex)
+ ex = :((() -> $ex)()) | base/timing.jl | 26 | Julia | 0.429 | refactor | 115 | 51 | 51 | false | change `@allocated` again | 59,278 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | JeffBezanson | Review this pull request change.
Language: Julia
File: base/timing.jl
PR Title: change `@allocated` again
BEFORE CODE: return b1[] - b0[]
end
only(methods(allocated)).called = 0xff
@constprop :none function allocations(f, args::Vararg{Any,N}) where {N}
stats = Base.gc_num()
val = f(args...)
diff = ... | My new doc string is not entirely consistent with this. We may want to remove this as it's kind of hard to explain. | 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. |
"""
cmd = if Sys.isunix()
# Set the maximum core dump size to 0 to keep this expected crash from
# producing a (and potentially overwriting an existing) core dump file
`sh -c "ulimit -c 0; $(Base.shell_escape(Base.julia_cmd())) -e $(Base.shell_escape(script))"`
else
`$(Base.j... | ```suggestion
# a function that allocates iff no constprop
``` | """
cmd = if Sys.isunix()
# Set the maximum core dump size to 0 to keep this expected crash from
# producing a (and potentially overwriting an existing) core dump file
`sh -c "ulimit -c 0; $(Base.shell_escape(Base.julia_cmd())) -e $(Base.shell_escape(script))"`
else
`$(Base.j... | @@ -1540,15 +1540,39 @@ end
# issue #41656
run(`$(Base.julia_cmd()) -e 'isempty(x) = true'`)
+function treshape59278(X::AbstractArray, n, m)
+ Y = reshape(X, n, m)
+ Y .= 1.0
+ return X
+end
+
+# a funcion that allocates iff no constprop | test/misc.jl | 26 | Julia | 0.571 | suggestion | 64 | 51 | 51 | false | change `@allocated` again | 59,278 | JuliaLang/julia | 35,573 | Julia | JeffBezanson | JeffBezanson | Review this pull request change.
Language: Julia
File: test/misc.jl
PR Title: change `@allocated` again
BEFORE CODE: """
cmd = if Sys.isunix()
# Set the maximum core dump size to 0 to keep this expected crash from
# producing a (and potentially overwriting an existing) core dump file
... | ```suggestion
# a function that allocates iff no constprop
``` | 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. |
catch e
isa(e, InterruptException) || rethrow()
finally
REPL.Terminals.raw!(term, false)
end
end
end
o_ts_duration = @elapsed Experimental.@sync begin
for p in workers()
@async... | Could simplify a tiny bit as
```suggestion
hours, mins = divrem(elapsed_minutes, 60)
``` | for p in workers()
@async begin
push!(all_tasks, current_task())
while length(tests) > 0
test = popfirst!(tests)
running_tests[test] = now()
wrkr = p
# Cre... | @@ -262,6 +277,34 @@ cd(@__DIR__) do
test = popfirst!(tests)
running_tests[test] = now()
wrkr = p
+
+ # Create a timer for this test to report long-running status
+ test_timers[test] = Timer(longrunn... | test/runtests.jl | 26 | Julia | 0.786 | refactor | 127 | 51 | 51 | false | Add a long running warn to Base.runtests | 59,288 | JuliaLang/julia | 35,573 | Julia | ararslan | IanButterworth | Review this pull request change.
Language: Julia
File: test/runtests.jl
PR Title: Add a long running warn to Base.runtests
BEFORE CODE: catch e
isa(e, InterruptException) || rethrow()
finally
REPL.Terminals.raw!(term, false)
end... | Could simplify a tiny bit as
```suggestion
hours, mins = divrem(elapsed_minutes, 60)
``` | 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
using Test
using Distributed
using Dates
if !Sys.iswindows() && isa(stdin, Base.TTY)
import REPL
end
using Printf: @sprintf
using Base: Experimental
include("choosetests.jl")
include("testenv.jl")
include("buildkitetestjson.jl")
longru... | Could use `get` instead of `if haskey` + `getindex`? | # This file is a part of Julia. License is MIT: https://julialang.org/license
using Test
using Distributed
using Dates
if !Sys.iswindows() && isa(stdin, Base.TTY)
import REPL
end
using Printf: @sprintf
using Base: Experimental
include("choosetests.jl")
include("testenv.jl")
include("buildkitetestjson.jl")
const ... | @@ -13,6 +13,17 @@ include("choosetests.jl")
include("testenv.jl")
include("buildkitetestjson.jl")
+longrunning_delay = if haskey(ENV, "JULIA_TEST_LONGRUNNING_DELAY") # minutes
+ parse(Int, ENV["JULIA_TEST_LONGRUNNING_DELAY"]) * 60
+else
+ 45 * 60 # 45 minutes
+end
+longrunning_interval = if haskey(ENV, "JUL... | test/runtests.jl | 25 | Julia | 0.429 | question | 52 | 50 | 50 | false | Add a long running warn to Base.runtests | 59,288 | JuliaLang/julia | 35,573 | Julia | giordano | IanButterworth | Review this pull request change.
Language: Julia
File: test/runtests.jl
PR Title: Add a long running warn to Base.runtests
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
using Test
using Distributed
using Dates
if !Sys.iswindows() && isa(stdin, Base.TTY)
import REPL
... | Could use `get` instead of `if haskey` + `getindex`? | 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 recorded_error isa Test.Error
@test recorded_error.context !== nothing
@test occursin("x = 42", recorded_error.context)
# Context shows up in string representation
error_str = sprint(show, recorded_error)
@test occursin("Context:", error_str)
@test occursin... | This doesn't work if it's captured with OncePerProcess | @test recorded_error isa Test.Error
@test recorded_error.context !== nothing
@test occursin("x = 42", recorded_error.context)
# Context shows up in string representation
error_str = sprint(show, recorded_error)
@test occursin("Context:", error_str)
@test occursin... | @@ -2008,3 +2008,56 @@ end
@test occursin("(x, y) = (42, \"hello\")", recorded_error2.context)
end
end
+
+@testset "JULIA_TEST_VERBOSE" begin
+ # Test the verbose testset entry/exit functionality
+ withenv("JULIA_TEST_VERBOSE" => "true") do | stdlib/Test/test/runtests.jl | 26 | Julia | 0.214 | suggestion | 54 | 51 | 51 | false | Add test verbose env var and show when starting/finishing testsets | 59,295 | JuliaLang/julia | 35,573 | Julia | Keno | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/Test/test/runtests.jl
PR Title: Add test verbose env var and show when starting/finishing testsets
BEFORE CODE: @test recorded_error isa Test.Error
@test recorded_error.context !== nothing
@test occursin("x = 42", recorded_error.c... | This doesn't work if it's captured with OncePerProcess | 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
# Patches to Base needed for trimming
@eval Core begin
DomainError(@nospecialize(val), @nospecialize(msg::AbstractString)) = (@noinline; $(Expr(:new, :DomainError, :val, :msg)))
end
(f::Base.RedirectStdStream)(io::Core.CoreSTDOUT) = Ba... | ```suggestion
# Disable logging (TypedCallable is required to support the existing dynamic
# logger interface, but it's not implemented yet)
@inline current_logger_for_env(std_level::LogLevel, group, _module) = nothing
``` | cglobal(:jl_gc_counted_realloc_with_old_size),
cglobal(:jl_gc_counted_free_with_size))
ZERO.alloc, ZERO.size, ZERO.d = 0, 0, C_NULL
ONE.alloc, ONE.size, ONE.d = 1, 1, pointer(_ONE)
catch ex
Base.showerror_nostdio(ex, "WARNING: Error during init... | @@ -109,3 +118,7 @@ end
end
end
end
+
+@eval Base.CoreLogging begin
+ @inline current_logger_for_env(std_level::LogLevel, group, _module) = nothing | contrib/juliac/juliac-trim-base.jl | 26 | Julia | 0.929 | suggestion | 238 | 125 | 28 | false | Fix printing of errors in juliac + searchsorted functions for LinearAlgebra | 59,299 | JuliaLang/julia | 35,573 | Julia | topolarity | gbaraldi | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-trim-base.jl
PR Title: Fix printing of errors in juliac + searchsorted functions for LinearAlgebra
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
# Patches to Base needed for trimming
@eval Cor... | ```suggestion
# Disable logging (TypedCallable is required to support the existing dynamic
# logger interface, but it's not implemented yet)
@inline current_logger_for_env(std_level::LogLevel, group, _module) = 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
elseif T isa Union
print(io, "Union{")
show_typeish(io, T.a)
print(io, ", ")
show_typeish(io, T.b)
print(io, "}")
elseif T isa UnionAll
print(io, T.body::Type)
print(io, " where ")
print(io, T... | ```suggestion
# identical to existing Base def. but specializes on `lt` / `by`
$s(v::AbstractVector, x, o::Ordering) = $s(v,x,firstindex(v),lastindex(v),o)
``` | end
elseif T isa Union
print(io, "Union{")
show_typeish(io, T.a)
print(io, ", ")
show_typeish(io, T.b)
print(io, "}")
elseif T isa UnionAll
print(io, T.body::Type)
print(io, " where ")
print(io, T... | @@ -82,6 +82,15 @@ end
@eval Base.Sys begin
__init_build() = nothing # VersionNumber parsing is not supported yet
end
+# Used for LinearAlgebre ldiv with SVD
+for s in [:searchsortedfirst, :searchsortedlast, :searchsorted]
+ @eval Base.Sort begin
+ $s(v::AbstractVector, x, o::Ordering) = $s(v,x,firstin... | contrib/juliac/juliac-trim-base.jl | 26 | Julia | 0.714 | refactor | 178 | 51 | 51 | false | Fix printing of errors in juliac + searchsorted functions for LinearAlgebra | 59,299 | JuliaLang/julia | 35,573 | Julia | topolarity | gbaraldi | Review this pull request change.
Language: Julia
File: contrib/juliac/juliac-trim-base.jl
PR Title: Fix printing of errors in juliac + searchsorted functions for LinearAlgebra
BEFORE CODE: end
elseif T isa Union
print(io, "Union{")
show_typeish(io, T.a)
print(... | ```suggestion
# identical to existing Base def. but specializes on `lt` / `by`
$s(v::AbstractVector, x, o::Ordering) = $s(v,x,firstindex(v),lastindex(v),o)
``` | 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> b = dropdims(a; dims=3)
2×2×1 Array{Int64, 3}:
[:, :, 1] =
1 3
2 4
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
dropdims(A; dims) = _dropdims(A, dims)
function _dropdims(A::AbstractArray, dims::Dims)
for i in eachindex(dims)
1 <= dims[i] <= ndims(A) || thro... | slightly simpler:
```suggestion
if isconcretetype(eltype(ox))
``` |
julia> b = dropdims(a; dims=3)
2×2×1 Array{Int64, 3}:
[:, :, 1] =
1 3
2 4
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
dropdims(A; dims) = _dropdims(A, dims)
function _dropdims(A::AbstractArray, dims::Dims)
for i in eachindex(dims)
1 <= dims[i] <= ndims(A) || thro... | @@ -88,12 +88,18 @@ function _dropdims(A::AbstractArray, dims::Dims)
dims[j] == dims[i] && throw(ArgumentError("dropped dims must be unique"))
end
end
+ ox = axes(A)
ax = _foldoneto((ds, d) -> d in dims ? ds : (ds..., axes(A,d)), (), Val(ndims(A)))
- reshape(A, ax::typeof(_sub(axes... | base/abstractarraymath.jl | 26 | Julia | 0.714 | suggestion | 74 | 51 | 51 | false | don't assume homogenous axes types in `dropdims` | 59,302 | JuliaLang/julia | 35,573 | Julia | nsajko | adienes | Review this pull request change.
Language: Julia
File: base/abstractarraymath.jl
PR Title: don't assume homogenous axes types in `dropdims`
BEFORE CODE:
julia> b = dropdims(a; dims=3)
2×2×1 Array{Int64, 3}:
[:, :, 1] =
1 3
2 4
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
... | slightly simpler:
```suggestion
if isconcretetype(eltype(ox))
``` | 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> b = dropdims(a; dims=3)
2×2×1 Array{Int64, 3}:
[:, :, 1] =
1 3
2 4
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
dropdims(A; dims) = _dropdims(A, dims)
function _dropdims(A::AbstractArray, dims::Dims)
for i in eachindex(dims)
1 <= dims[i] <= ndims(A) || throw... | ```suggestion
# if all the axes are the same type, we can use the tail as the
``` | julia> b = dropdims(a; dims=3)
2×2×1 Array{Int64, 3}:
[:, :, 1] =
1 3
2 4
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
dropdims(A; dims) = _dropdims(A, dims)
function _dropdims(A::AbstractArray, dims::Dims)
for i in eachindex(dims)
1 <= dims[i] <= ndims(A) || throw... | @@ -88,12 +88,18 @@ function _dropdims(A::AbstractArray, dims::Dims)
dims[j] == dims[i] && throw(ArgumentError("dropped dims must be unique"))
end
end
+ ox = axes(A)
ax = _foldoneto((ds, d) -> d in dims ? ds : (ds..., axes(A,d)), (), Val(ndims(A)))
- reshape(A, ax::typeof(_sub(axes... | base/abstractarraymath.jl | 26 | Julia | 0.786 | suggestion | 91 | 51 | 51 | false | don't assume homogenous axes types in `dropdims` | 59,302 | JuliaLang/julia | 35,573 | Julia | adienes | adienes | Review this pull request change.
Language: Julia
File: base/abstractarraymath.jl
PR Title: don't assume homogenous axes types in `dropdims`
BEFORE CODE: julia> b = dropdims(a; dims=3)
2×2×1 Array{Int64, 3}:
[:, :, 1] =
1 3
2 4
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
d... | ```suggestion
# if all the axes are the same type, we can use the tail as 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. |
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
dropdims(A; dims) = _dropdims(A, dims)
function _dropdims(A::AbstractArray, dims::Dims)
for i in eachindex(dims)
1 <= dims[i] <= ndims(A) || throw(ArgumentError("dropped dims must be in range 1:ndims(A)"))
length(axe... | I'd deduplicate this by moving the `reshape` call out of the branch (assuming the `typeassert` is necessary in the first place):
```suggestion
if isconcretetype(eltype(ox))
# if all the axes are the same type, we can use the tail as the
# axes of the result rather than extracting one at each i... |
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
dropdims(A; dims) = _dropdims(A, dims)
function _dropdims(A::AbstractArray, dims::Dims)
for i in eachindex(dims)
1 <= dims[i] <= ndims(A) || throw(ArgumentError("dropped dims must be in range 1:ndims(A)"))
length(axe... | @@ -88,12 +88,18 @@ function _dropdims(A::AbstractArray, dims::Dims)
dims[j] == dims[i] && throw(ArgumentError("dropped dims must be unique"))
end
end
+ ox = axes(A)
ax = _foldoneto((ds, d) -> d in dims ? ds : (ds..., axes(A,d)), (), Val(ndims(A)))
- reshape(A, ax::typeof(_sub(axes... | base/abstractarraymath.jl | 26 | Julia | 1 | refactor | 406 | 51 | 51 | false | don't assume homogenous axes types in `dropdims` | 59,302 | JuliaLang/julia | 35,573 | Julia | nsajko | adienes | Review this pull request change.
Language: Julia
File: base/abstractarraymath.jl
PR Title: don't assume homogenous axes types in `dropdims`
BEFORE CODE:
julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
5 3
2 4
```
"""
dropdims(A; dims) = _dropdims(A, dims)
function _dropdims(A::AbstractArray, dim... | I'd deduplicate this by moving the `reshape` call out of the branch (assuming the `typeassert` is necessary in the first place):
```suggestion
if isconcretetype(eltype(ox))
# if all the axes are the same type, we can use the tail as the
# axes of the result rather than extracting one at each i... | 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. |
methods(j59327)[1].specializations
)
@noinline l59327(f::Base.Callable, x) = Any[f, x]
m59327(x) = l59327(+, Any[x][1])
m59327(1)
@test any(
mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(l59327), Function, Int},
methods(l59327)[1].specializations
)
# _do_ specialize if the signature has a... | is there a typo here?
```suggestion
@noinline n59327(f::typeof(+), x) = Any[f, x]
``` | methods(j59327)[1].specializations
)
@noinline l59327(f::Base.Callable, x) = Any[f, x]
m59327(x) = l59327(+, Any[x][1])
m59327(1)
@test any(
mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(l59327), Function, Int},
methods(l59327)[1].specializations
)
# _do_ specialize if the signature has a... | @@ -243,6 +243,62 @@ k11840(::Type{Union{Tuple{Int32}, Tuple{Int64}}}) = '2'
@test k11840(Tuple{Union{Int32, Int64}}) == '2'
@test k11840(Union{Tuple{Int32}, Tuple{Int64}}) == '2'
+# issue #59327
+@noinline f59327(f, x) = Any[f, x]
+g59327(x) = f59327(+, Any[x][1])
+g59327(1)
+@test any(
+ mi->mi isa Core.Method... | test/core.jl | 26 | Julia | 0.714 | suggestion | 89 | 51 | 51 | false | Fix nospecializing Functions in `Union{Nothing,Function}` params | 59,327 | JuliaLang/julia | 35,573 | Julia | nickrobinson251 | NHDaly | Review this pull request change.
Language: Julia
File: test/core.jl
PR Title: Fix nospecializing Functions in `Union{Nothing,Function}` params
BEFORE CODE: methods(j59327)[1].specializations
)
@noinline l59327(f::Base.Callable, x) = Any[f, x]
m59327(x) = l59327(+, Any[x][1])
m59327(1)
@test any(
mi->mi isa... | is there a typo here?
```suggestion
@noinline n59327(f::typeof(+), x) = Any[f, x]
``` | 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 it has a current usage with ExternalLinkage
auto jl_small_typeof_copy = dataM.getGlobalVariable("jl_small_typeof");
if (jl_small_typeof_copy) {
jl_small_typeof_copy->setVisibility(GlobalValue::HiddenVisibility);
jl_small_typeof_copy->setDSOLocal(... | We might be able to use modern C++ features for this (though it might require replacing `std::function` with `llvm::unique_function`, which hasn't yet been standardized, so that it compiles to do the right thing)
```suggestion
data_outputs = compile(*dataM, "text", threads, [data, lock = std::move(lock), TSCt... | // if it has a current usage with ExternalLinkage
auto jl_small_typeof_copy = dataM.getGlobalVariable("jl_small_typeof");
if (jl_small_typeof_copy) {
jl_small_typeof_copy->setVisibility(GlobalValue::HiddenVisibility);
jl_small_typeof_copy->setDSOLocal(... | @@ -2271,9 +2271,14 @@ void jl_dump_native_impl(void *native_code,
auto lock = TSCtx.getLock();
auto dataM = data->M.getModuleUnlocked();
- // Delete data when add_output thinks it's done with it
- // Saves memory for use when multithreading
- data_outputs = compile(*dataM, "tex... | src/aotcompile.cpp | 26 | C++ | 1 | suggestion | 523 | 51 | 51 | false | aotcompile: destroy LLVM context after serializing combined module | 59,329 | JuliaLang/julia | 35,573 | Julia | vtjnash | xal-0 | Review this pull request change.
Language: C++
File: src/aotcompile.cpp
PR Title: aotcompile: destroy LLVM context after serializing combined module
BEFORE CODE: // if it has a current usage with ExternalLinkage
auto jl_small_typeof_copy = dataM.getGlobalVariable("jl_small_typeof");
... | We might be able to use modern C++ features for this (though it might require replacing `std::function` with `llvm::unique_function`, which hasn't yet been standardized, so that it compiles to do the right thing)
```suggestion
data_outputs = compile(*dataM, "text", threads, [data, lock = std::move(lock), TSCt... | 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. |
Dynamic scopes are propagated across tasks.
# Examples
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with(sval => 2) do
sval[]
end
2
julia> sval[]
1
```
!!! compat "Julia 1.11"
Scoped values were introduced in Julia 1.11. In Julia 1.... | Isn't this considered breaking, since `ScopedValue{Foo}` is no longer concrete? Why not create a new abstract type and make `ScopedValue` subtype that, thereby making handling of `LazyScopedValue` opt-in? |
Create a container that propagates values across dynamic scopes.
Use [`with`](@ref) to create and enter a new dynamic scope.
Values can only be set when entering a new dynamic scope,
and the value referred to will be constant during the
execution of a dynamic scope.
Dynamic scopes are propagated across tasks.
# Exa... | @@ -40,17 +80,13 @@ julia> sval[]
Scoped values were introduced in Julia 1.11. In Julia 1.8+ a compatible
implementation is available from the package ScopedValues.jl.
"""
-mutable struct ScopedValue{T}
- # NOTE this struct must be defined as mutable one since it's used as a key of
- # `ScopeStora... | base/scopedvalues.jl | 26 | Julia | 0.786 | refactor | 205 | 51 | 51 | false | Allow ScopedValue defaults to be lazily computed | 59,372 | JuliaLang/julia | 35,573 | Julia | Seelengrab | Keno | Review this pull request change.
Language: Julia
File: base/scopedvalues.jl
PR Title: Allow ScopedValue defaults to be lazily computed
BEFORE CODE: Dynamic scopes are propagated across tasks.
# Examples
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with... | Isn't this considered breaking, since `ScopedValue{Foo}` is no longer concrete? Why not create a new abstract type and make `ScopedValue` subtype that, thereby making handling of `LazyScopedValue` opt-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. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
module ScopedValues
export ScopedValue, LazyScopedValue, with, @with
public get
"""
AbstractScopedValue{T}
Abstract base type for scoped values that propagate values across
dynamic scopes. All scoped value types must extend this abstr... | ```suggestion
See also: [`ScopedValue`](@ref), [`LazyScopedValue`](@ref)
!!! compat "Julia 1.13"
AbstractScopedValue requires Julia 1.13+.
``` | # This file is a part of Julia. License is MIT: https://julialang.org/license
module ScopedValues
export ScopedValue, LazyScopedValue, with, @with
public get
"""
AbstractScopedValue{T}
Abstract base type for scoped values that propagate values across
dynamic scopes. All scoped value types must extend this abstr... | @@ -2,9 +2,54 @@
module ScopedValues
-export ScopedValue, with, @with
+export ScopedValue, LazyScopedValue, with, @with
public get
+"""
+ AbstractScopedValue{T}
+
+Abstract base type for scoped values that propagate values across
+dynamic scopes. All scoped value types must extend this abstract type.
+
+See ... | base/scopedvalues.jl | 14 | Julia | 0.714 | refactor | 152 | 39 | 39 | false | Allow ScopedValue defaults to be lazily computed | 59,372 | JuliaLang/julia | 35,573 | Julia | vchuravy | Keno | Review this pull request change.
Language: Julia
File: base/scopedvalues.jl
PR Title: Allow ScopedValue defaults to be lazily computed
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
module ScopedValues
export ScopedValue, LazyScopedValue, with, @with
public get
"""
... | ```suggestion
See also: [`ScopedValue`](@ref), [`LazyScopedValue`](@ref)
!!! compat "Julia 1.13"
AbstractScopedValue requires Julia 1.13+.
``` | 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> ScopedValues.get(a)
Some(42)
julia> isnothing(ScopedValues.get(b))
true
```
"""
function get(val::AbstractScopedValue{T}) where {T}
scope = Core.current_scope()::Union{Scope, Nothing}
if scope === nothing
!hasdefault(val) && return nothing
return Some{T}(getdefault(val))
end
sco... | Is this something that was missing before? (I hope this doesn't lead to more allocations) | # Examples
```jldoctest
julia> using Base.ScopedValues
julia> a = ScopedValue(42); b = ScopedValue{Int}();
julia> ScopedValues.get(a)
Some(42)
julia> isnothing(ScopedValues.get(b))
true
```
"""
function get(val::AbstractScopedValue{T}) where {T}
scope = Core.current_scope()::Union{Scope, Nothing}
if scope ==... | @@ -148,31 +195,36 @@ julia> isnothing(ScopedValues.get(b))
true
```
"""
-function get(val::ScopedValue{T}) where {T}
+function get(val::AbstractScopedValue{T}) where {T}
scope = Core.current_scope()::Union{Scope, Nothing}
if scope === nothing
- val.has_default && return Some{T}(val.default)
- ... | base/scopedvalues.jl | 26 | Julia | 0.214 | question | 89 | 51 | 51 | false | Allow ScopedValue defaults to be lazily computed | 59,372 | JuliaLang/julia | 35,573 | Julia | vchuravy | Keno | Review this pull request change.
Language: Julia
File: base/scopedvalues.jl
PR Title: Allow ScopedValue defaults to be lazily computed
BEFORE CODE:
julia> ScopedValues.get(a)
Some(42)
julia> isnothing(ScopedValues.get(b))
true
```
"""
function get(val::AbstractScopedValue{T}) where {T}
scope = Core.current_sc... | Is this something that was missing before? (I hope this doesn't lead to more allocations) | 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. |
Dynamic scopes are propagated across tasks.
# Examples
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with(sval => 2) do
sval[]
end
2
julia> sval[]
1
```
!!! compat "Julia 1.11"
Scoped values were introduced in Julia 1.11. In Julia 1.... | ```suggestion
mutable struct ScopedValue{T} <: AbstractScopedValue{T}
# NOTE this struct must be defined as mutable one since it's used as a key of
# `ScopeStorage` dictionary and thus needs object identity
``` | Dynamic scopes are propagated across tasks.
# Examples
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with(sval => 2) do
sval[]
end
2
julia> sval[]
1
```
!!! compat "Julia 1.11"
Scoped values were introduced in Julia 1.11. In Julia 1.... | @@ -40,17 +88,21 @@ julia> sval[]
Scoped values were introduced in Julia 1.11. In Julia 1.8+ a compatible
implementation is available from the package ScopedValues.jl.
"""
-mutable struct ScopedValue{T}
- # NOTE this struct must be defined as mutable one since it's used as a key of
- # `ScopeStora... | base/scopedvalues.jl | 26 | Julia | 0.857 | refactor | 227 | 51 | 51 | false | Allow ScopedValue defaults to be lazily computed | 59,372 | JuliaLang/julia | 35,573 | Julia | IanButterworth | Keno | Review this pull request change.
Language: Julia
File: base/scopedvalues.jl
PR Title: Allow ScopedValue defaults to be lazily computed
BEFORE CODE: Dynamic scopes are propagated across tasks.
# Examples
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with... | ```suggestion
mutable struct ScopedValue{T} <: AbstractScopedValue{T}
# NOTE this struct must be defined as mutable one since it's used as a key of
# `ScopeStorage` dictionary and thus needs object identity
``` | 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. |
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with(sval => 2) do
sval[]
end
2
julia> sval[]
1
```
!!! compat "Julia 1.11"
Scoped values were introduced in Julia 1.11. In Julia 1.8+ a compatible
implementation is available from the... | ```suggestion
const hasdefault::Bool # this field is necessary since isbitstype `default` field may be initialized with undefined value
``` |
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with(sval => 2) do
sval[]
end
2
julia> sval[]
1
```
!!! compat "Julia 1.11"
Scoped values were introduced in Julia 1.11. In Julia 1.8+ a compatible
implementation is available from the... | @@ -40,17 +88,23 @@ julia> sval[]
Scoped values were introduced in Julia 1.11. In Julia 1.8+ a compatible
implementation is available from the package ScopedValues.jl.
"""
-mutable struct ScopedValue{T}
+mutable struct ScopedValue{T} <: AbstractScopedValue{T}
# NOTE this struct must be defined as mutabl... | base/scopedvalues.jl | 26 | Julia | 0.857 | suggestion | 145 | 51 | 51 | false | Allow ScopedValue defaults to be lazily computed | 59,372 | JuliaLang/julia | 35,573 | Julia | Seelengrab | Keno | Review this pull request change.
Language: Julia
File: base/scopedvalues.jl
PR Title: Allow ScopedValue defaults to be lazily computed
BEFORE CODE:
```jldoctest
julia> using Base.ScopedValues;
julia> const sval = ScopedValue(1);
julia> sval[]
1
julia> with(sval => 2) do
sval[]
end
2
julia> sv... | ```suggestion
const hasdefault::Bool # this field is necessary since isbitstype `default` field may be initialized with undefined 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. |
# This file is a part of Julia. License is MIT: https://julialang.org/license
###################################
# Cross Platform tests for spawn. #
###################################
using Random, Sockets, SHA
using Downloads: Downloads, download
valgrind_off = ccall(:jl_running_on_valgrind, Cint, ()) == 0
yescm... | I assume it is officially disallowed, but does it do any verification, or would the test pass if attempted? Since passing sockets at all is also officially documented as broken in the NT kernel due to various ancient design and implementation mistakes of long deprecated APIs around WSADuplicateSocket/DuplicateHandle, b... | # effects for Cmd construction
for f in (() -> `a b c`, () -> `a a$("bb")a $("c")`)
effects = Base.infer_effects(f)
@test Core.Compiler.is_effect_free(effects)
@test Core.Compiler.is_terminates(effects)
@test Core.Compiler.is_noub(effects)
@test !Core.Compiler.is_consistent(effects)
end
let effects ... | @@ -1053,3 +1053,34 @@ end
@assert eltype(args) != String
@test Cmd(["ls", args...]) == `ls -l /tmp`
end
+
+# Test passing a pipe server as an addition fd
+@testset "Pipe server as additional fd" begin
+ if !Sys.iswindows()
+ # Windows CRT does not support passing server sockets as stdio fds | test/spawn.jl | 26 | Julia | 0.571 | bug | 390 | 1,056 | 51 | false | spawn: Allow libuv IOServers to be passed as extra FDs | 59,373 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: Julia
File: test/spawn.jl
PR Title: spawn: Allow libuv IOServers to be passed as extra FDs
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
###################################
# Cross Platform tests for spawn. #
##################... | I assume it is officially disallowed, but does it do any verification, or would the test pass if attempted? Since passing sockets at all is also officially documented as broken in the NT kernel due to various ancient design and implementation mistakes of long deprecated APIs around WSADuplicateSocket/DuplicateHandle, 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. |
@testset for i in 1:6
iseven(i) || error("error outside of test")
@test true # only gets run if the above passed
end
end
end
# These lines shouldn't be called
error("No exception was thrown!")
catch ex
... | maybe switch to 0x0? to reflect the new type (or an enum) | @testset for i in 1:6
iseven(i) || error("error outside of test")
@test true # only gets run if the above passed
end
end
end
# These lines shouldn't be called
error("No exception was thrown!")
catch ex
... | @@ -584,7 +584,7 @@ end
@test total_error == 6
@test total_broken == 0
end
- ts.anynonpass = false
+ @atomic ts.anynonpass = false | stdlib/Test/test/runtests.jl | 26 | Julia | 0.357 | suggestion | 57 | 51 | 51 | false | Test: Make test recording thread safe | 59,374 | JuliaLang/julia | 35,573 | Julia | gbaraldi | Keno | Review this pull request change.
Language: Julia
File: stdlib/Test/test/runtests.jl
PR Title: Test: Make test recording thread safe
BEFORE CODE: @testset for i in 1:6
iseven(i) || error("error outside of test")
@test true # only gets run if the above passed
... | maybe switch to 0x0? to reflect the new type (or an enum) | 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. |
new_error = Error(t.test_type, t.orig_expr, t.value, t.backtrace, context, t.source)
record(c.parent_ts, new_error)
end
#-----------------------------------------------------------------------
"""
DefaultTestSet
If using the DefaultTestSet, the test results will be recorded. If there
are any `Fail`s or `... | e.g.
```suggestion
# Warning: `results_lock` must be held before accessing any of the following fields
rng::Union{Nothing,AbstractRNG}
n_passed::Int
time_end::Float64
``` | new_error = Error(t.test_type, t.orig_expr, t.value, t.backtrace, context, t.source)
record(c.parent_ts, new_error)
end
#-----------------------------------------------------------------------
"""
DefaultTestSet
If using the DefaultTestSet, the test results will be recorded. If there
are any `Fail`s or `... | @@ -1208,17 +1208,27 @@ are any `Fail`s or `Error`s, an exception will be thrown only at the end,
along with a summary of the test results.
"""
mutable struct DefaultTestSet <: AbstractTestSet
- description::String
- results::Vector{Any}
- n_passed::Int
- anynonpass::Bool
- verbose::Bool
- showtimi... | stdlib/Test/src/Test.jl | 26 | Julia | 0.714 | refactor | 192 | 51 | 51 | false | Test: Make test recording thread safe | 59,374 | JuliaLang/julia | 35,573 | Julia | vtjnash | Keno | Review this pull request change.
Language: Julia
File: stdlib/Test/src/Test.jl
PR Title: Test: Make test recording thread safe
BEFORE CODE: new_error = Error(t.test_type, t.orig_expr, t.value, t.backtrace, context, t.source)
record(c.parent_ts, new_error)
end
#----------------------------------------------... | e.g.
```suggestion
# Warning: `results_lock` must be held before accessing any of the following fields
rng::Union{Nothing,AbstractRNG}
n_passed::Int
time_end::Float64
``` | 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. |
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equivalent to
```
if x isa T1
f(x, y, z)
elseif x isa T2
f(x, y, z)
else
f(x, y, z)
end
```
"""
function union_split(f::F, @... | ```suggestion
function hash_shaped(A, h0::UInt, eltype_hint=())
```
(and elsewhere) | # This file is a part of Julia. License is MIT: https://julialang.org/license
### Multidimensional iterators
module IteratorsMD
import .Base: eltype, length, size, first, last, in, getindex, setindex!,
min, max, zero, oneunit, isless, eachindex,
convert, show, iterate, promote_r... | @@ -2083,7 +2083,34 @@ function _hash_fib(A, h::UInt)
return hash_uint(h)
end
-function hash_shaped(A, h::UInt)
+"""
+ union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
+
+call `f(x, args...)`, union-splitting on all the types specified by `ts`
+
+`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equival... | base/multidimensional.jl | 26 | Julia | 0.714 | suggestion | 88 | 51 | 2,109 | false | Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s | 59,378 | JuliaLang/julia | 35,573 | Julia | adienes | LilithHafner | Review this pull request change.
Language: Julia
File: base/multidimensional.jl
PR Title: Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s
BEFORE CODE: union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`union_s... | ```suggestion
function hash_shaped(A, h0::UInt, eltype_hint=())
```
(and elsewhere) | 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
f(x, y, z)
end
```
"""
function union_split(f::F, @nospecialize(x), ts::Tuple{Val{T}, Vararg{Any,N}}, args...) where {F, T, N}
if x isa T
f(x::T, args...)
else
union_split(f, x, Base.tail(ts), args...)
end
end
union_split(f::F, @nospecialize(x), ::Tuple{}, args...) where F = f(x, ar... | why `@inline` ... inline, rather than `@inline function union_split` originally? | # This file is a part of Julia. License is MIT: https://julialang.org/license
### Multidimensional iterators
module IteratorsMD
import .Base: eltype, length, size, first, last, in, getindex, setindex!,
min, max, zero, oneunit, isless, eachindex,
convert, show, iterate, promote_r... | @@ -2093,20 +2120,20 @@ function hash_shaped(A, h::UInt)
if len < 8
# for the shortest arrays we chain directly
for elt in A
- h = hash(elt, h)
+ h = @inline union_split(hash, elt, eltpye_hint, h) | base/multidimensional.jl | 26 | Julia | 0.357 | question | 80 | 51 | 2,109 | false | Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s | 59,378 | JuliaLang/julia | 35,573 | Julia | adienes | LilithHafner | Review this pull request change.
Language: Julia
File: base/multidimensional.jl
PR Title: Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s
BEFORE CODE: else
f(x, y, z)
end
```
"""
function union_split(f::F, @nospecialize(x), ts::Tuple{Val{T}, Vararg{Any,N}}, args...) where {F, T, N}
... | why `@inline` ... inline, rather than `@inline function union_split` originally? | 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
@nexprs 4 i -> h = hash_mix_linear(p_i, h)
return hash_uint(h)
end
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equivalent to
```
if x isa T1
f(x, y, z)
el... | Pretty sure inference can figure `x isa T` on its own in this branch.
```suggestion
f(x, args...)
``` | if len < 8
# for the shortest arrays we chain directly
for elt in A
h = union_split(hash, elt, eltype_hint, h)
end
return h
elseif len < 32768
# separate accumulator streams, unrolled
@nexprs 8 i -> p_i::UInt = h
n = 1
limit = len - 7
... | @@ -2083,7 +2083,34 @@ function _hash_fib(A, h::UInt)
return hash_uint(h)
end
-function hash_shaped(A, h::UInt)
+"""
+ union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
+
+call `f(x, args...)`, union-splitting on all the types specified by `ts`
+
+`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equival... | base/multidimensional.jl | 26 | Julia | 0.714 | suggestion | 114 | 51 | 30 | false | Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s | 59,378 | JuliaLang/julia | 35,573 | Julia | nsajko | LilithHafner | Review this pull request change.
Language: Julia
File: base/multidimensional.jl
PR Title: Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s
BEFORE CODE: end
@nexprs 4 i -> h = hash_mix_linear(p_i, h)
return hash_uint(h)
end
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, arg... | Pretty sure inference can figure `x isa T` on its own in this branch.
```suggestion
f(x, 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. |
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equivalent to
```
if x isa T1
f(x, y, z)
elseif x isa T2
f(x, y, z)
else
f(x, y, z)
end
```
"""
@inline function union_... | @adienes, I suspect there is never a penalty in the `eltype_hint = ()` case but this would make me more sure:
```suggestion
@inline union_split(f::F, x, ::Tuple{}, args...) where F = f(x, args...)
``` | # This file is a part of Julia. License is MIT: https://julialang.org/license
### Multidimensional iterators
module IteratorsMD
import .Base: eltype, length, size, first, last, in, getindex, setindex!,
min, max, zero, oneunit, isless, eachindex,
convert, show, iterate, promote_r... | @@ -2083,7 +2083,34 @@ function _hash_fib(A, h::UInt)
return hash_uint(h)
end
-function hash_shaped(A, h::UInt)
+"""
+ union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
+
+call `f(x, args...)`, union-splitting on all the types specified by `ts`
+
+`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equival... | base/multidimensional.jl | 26 | Julia | 0.929 | suggestion | 203 | 51 | 2,109 | false | Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s | 59,378 | JuliaLang/julia | 35,573 | Julia | LilithHafner | LilithHafner | Review this pull request change.
Language: Julia
File: base/multidimensional.jl
PR Title: Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s
BEFORE CODE:
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`un... | @adienes, I suspect there is never a penalty in the `eltype_hint = ()` case but this would make me more sure:
```suggestion
@inline union_split(f::F, x, ::Tuple{}, args...) where F = f(x, 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. |
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equivalent to
```
if x isa T1
f(x, y, z)
elseif x isa T2
f(x, y, z)
else
f(x, y, z)
end
```
"""
@inline function union_... | ```suggestion
@inline union_split(f, x, ::Tuple{}, args...) = f(x, args...)
``` | # This file is a part of Julia. License is MIT: https://julialang.org/license
### Multidimensional iterators
module IteratorsMD
import .Base: eltype, length, size, first, last, in, getindex, setindex!,
min, max, zero, oneunit, isless, eachindex,
convert, show, iterate, promote_r... | @@ -2083,7 +2083,34 @@ function _hash_fib(A, h::UInt)
return hash_uint(h)
end
-function hash_shaped(A, h::UInt)
+"""
+ union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
+
+call `f(x, args...)`, union-splitting on all the types specified by `ts`
+
+`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equival... | base/multidimensional.jl | 26 | Julia | 0.571 | suggestion | 81 | 51 | 2,109 | false | Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s | 59,378 | JuliaLang/julia | 35,573 | Julia | adienes | LilithHafner | Review this pull request change.
Language: Julia
File: base/multidimensional.jl
PR Title: Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s
BEFORE CODE:
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`un... | ```suggestion
@inline union_split(f, x, ::Tuple{}, args...) = f(x, 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. |
keyidx = findprev(!isequal(elt), A, keyidx)
keyidx === nothing && break
end
@nexprs 4 i -> h = hash_mix_linear(p_i, h)
return hash_uint(h)
end
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`union_split(... | The intention is to only allow `Val` elements in the tuple, right? So the dispatch could be a bit stricter:
```suggestion
@inline function union_split(f, @nospecialize(x), ts::Tuple{Val{T}, Vararg{Val,N}}, args...) where {T, N}
```
Loving `union_split`, BTW! | len = length(A)
if len < 8
# for the shortest arrays we chain directly
for elt in A
h = union_split(hash, elt, eltype_hint, h)
end
return h
elseif len < 32768
# separate accumulator streams, unrolled
@nexprs 8 i -> p_i::UInt = h
n = 1
... | @@ -2083,7 +2083,34 @@ function _hash_fib(A, h::UInt)
return hash_uint(h)
end
-function hash_shaped(A, h::UInt)
+"""
+ union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
+
+call `f(x, args...)`, union-splitting on all the types specified by `ts`
+
+`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equival... | base/multidimensional.jl | 26 | Julia | 0.857 | suggestion | 266 | 51 | 32 | false | Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s | 59,378 | JuliaLang/julia | 35,573 | Julia | nsajko | LilithHafner | Review this pull request change.
Language: Julia
File: base/multidimensional.jl
PR Title: Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s
BEFORE CODE: keyidx = findprev(!isequal(elt), A, keyidx)
keyidx === nothing && break
end
@nexprs 4 i -> h = hash_mix_linear(p_... | The intention is to only allow `Val` elements in the tuple, right? So the dispatch could be a bit stricter:
```suggestion
@inline function union_split(f, @nospecialize(x), ts::Tuple{Val{T}, Vararg{Val,N}}, args...) where {T, N}
```
Loving `union_split`, BTW! | 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. |
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equivalent to
```
if x isa T1
f(x, y, z)
elseif x isa T2
f(x, y, z)
else
f(x, y, z)
end
```
"""
@inline function union_... | there's some rule about not specializing on splat vararg arguments, right? would it be even-more-assured there is no penalty in the `eltype_hint=()` case if we add a 1-arg method
`@inline union_split(f, x, ::Tuple{}, h) = f(x, h)` ? | # This file is a part of Julia. License is MIT: https://julialang.org/license
### Multidimensional iterators
module IteratorsMD
import .Base: eltype, length, size, first, last, in, getindex, setindex!,
min, max, zero, oneunit, isless, eachindex,
convert, show, iterate, promote_r... | @@ -2083,7 +2083,34 @@ function _hash_fib(A, h::UInt)
return hash_uint(h)
end
-function hash_shaped(A, h::UInt)
+"""
+ union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
+
+call `f(x, args...)`, union-splitting on all the types specified by `ts`
+
+`union_split(f, x, (Val{T1}(), Val{T2}()), y, z)` is equival... | base/multidimensional.jl | 26 | Julia | 0.714 | question | 233 | 51 | 2,109 | false | Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s | 59,378 | JuliaLang/julia | 35,573 | Julia | adienes | LilithHafner | Review this pull request change.
Language: Julia
File: base/multidimensional.jl
PR Title: Union-split on `Expr`, `Symbol`, and `LineNumberNode` when hashing `Expr`s
BEFORE CODE:
"""
union_split(f, x, ts::Tuple{Vararg{Val}}, args...)
call `f(x, args...)`, union-splitting on all the types specified by `ts`
`un... | there's some rule about not specializing on splat vararg arguments, right? would it be even-more-assured there is no penalty in the `eltype_hint=()` case if we add a 1-arg method
`@inline union_split(f, x, ::Tuple{}, h) = f(x, h)` ? | 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. |
to_indices(A, I::Tuple{Vararg{Integer}}) = (@inline; to_indices(A, (), I))
to_indices(A, inds, ::Tuple{}) = ()
to_indices(A, inds, I::Tuple{Any, Vararg}) =
(@inline; (to_index(A, I[1]), to_indices(A, safe_tail(inds), tail(I))...))
"""
Slice(indices)
Represent an AbstractUnitRange of indices as a vector of the... | Could this not be
```suggestion
axes(S::Slice{<:AbstractOneTo}) = (S.indices,)
```
? Why is `<:Integer` needed? | to_indices(A, I::Tuple{Vararg{Integer}}) = (@inline; to_indices(A, (), I))
to_indices(A, inds, ::Tuple{}) = ()
to_indices(A, inds, I::Tuple{Any, Vararg}) =
(@inline; (to_index(A, I[1]), to_indices(A, safe_tail(inds), tail(I))...))
"""
Slice(indices)
Represent an AbstractUnitRange of indices as a vector of the... | @@ -387,8 +387,8 @@ Slice{T}(S::Slice) where {T<:AbstractUnitRange} = Slice{T}(T(S.indices))
axes(S::Slice) = (IdentityUnitRange(S.indices),)
axes1(S::Slice) = IdentityUnitRange(S.indices)
-axes(S::Slice{<:OneTo}) = (S.indices,)
-axes1(S::Slice{<:OneTo}) = S.indices
+axes(S::Slice{<:AbstractOneTo{<:Integer}}) = (S.... | base/indices.jl | 26 | Julia | 0.786 | refactor | 112 | 51 | 51 | false | `axes` for a `Slice` of an `AbstractOneTo` axis | 59,384 | JuliaLang/julia | 35,573 | Julia | ararslan | jishnub | Review this pull request change.
Language: Julia
File: base/indices.jl
PR Title: `axes` for a `Slice` of an `AbstractOneTo` axis
BEFORE CODE: to_indices(A, I::Tuple{Vararg{Integer}}) = (@inline; to_indices(A, (), I))
to_indices(A, inds, ::Tuple{}) = ()
to_indices(A, inds, I::Tuple{Any, Vararg}) =
(@inline; (to_... | Could this not be
```suggestion
axes(S::Slice{<:AbstractOneTo}) = (S.indices,)
```
? Why is `<:Integer` 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. |
range(first(i) ? first(S) : last(S), length = last(i), step = Int(step(i)))
end
# Indexing with offset ranges should preserve the axes of the indices
# however, this is only really possible in general with OffsetArrays.
# In some cases, though, we may obtain correct results using Base ranges
# the following methods... | ```suggestion
function getindex(S<:AbstractOneTo{<:Integer}, I::IdentityUnitRange{<:AbstractUnitRange{<:Integer}})
```
to match the signature of `axes` and also `I::` ? | # Indexing with offset ranges should preserve the axes of the indices
# however, this is only really possible in general with OffsetArrays.
# In some cases, though, we may obtain correct results using Base ranges
# the following methods are added to allow OffsetArrays to dispatch on the first argument without ambiguiti... | @@ -465,11 +465,11 @@ end
show(io::IO, r::IdentityUnitRange) = print(io, "Base.IdentityUnitRange(", r.indices, ")")
iterate(S::IdentityUnitRange, s...) = iterate(S.indices, s...)
-# For OneTo, the values and indices of the values are identical, so this may be defined in Base.
+# For AbstractOneTo, the values and in... | base/indices.jl | 26 | Julia | 0.714 | refactor | 173 | 51 | 51 | false | `axes` for a `Slice` of an `AbstractOneTo` axis | 59,384 | JuliaLang/julia | 35,573 | Julia | adienes | jishnub | Review this pull request change.
Language: Julia
File: base/indices.jl
PR Title: `axes` for a `Slice` of an `AbstractOneTo` axis
BEFORE CODE: range(first(i) ? first(S) : last(S), length = last(i), step = Int(step(i)))
end
# Indexing with offset ranges should preserve the axes of the indices
# however, this is o... | ```suggestion
function getindex(S<:AbstractOneTo{<:Integer}, I::IdentityUnitRange{<:AbstractUnitRange{<:Integer}})
```
to match the signature of `axes` and also `I::` ? | 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_DLLEXPORT void jl_gdblookup(void* ip)
{
jl_print_native_codeloc((uintptr_t)ip);
}
// Print backtrace for current exception in catch block
JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT
{
jl_task_t *ct = jl_current_task;
if (ct->ptls == NULL)
return;
jl_excstack_t *s = ct->excstack;
... | ```suggestion
jl_task_t *ct = jl_get_current_task();
``` | JL_DLLEXPORT void jl_gdblookup(void* ip)
{
jl_fprint_native_codeloc(ios_safe_stderr, (uintptr_t)ip);
}
// Print backtrace for current exception in catch block
JL_DLLEXPORT void jl_fprint_backtrace(ios_t *s) JL_NOTSAFEPOINT
{
jl_task_t *ct = jl_current_task;
if (ct->ptls == NULL)
return;
jl_excs... | @@ -1387,11 +1387,19 @@ JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT
// Print backtrace for specified task to jl_safe_printf stderr
JL_DLLEXPORT void jlbacktracet(jl_task_t *t) JL_NOTSAFEPOINT
{
+ jl_bt_element_t *bt_data;
jl_task_t *ct = jl_current_task; | src/stackwalk.c | 26 | C | 0.571 | suggestion | 62 | 51 | 51 | false | Print task backtraces on sigquit | 59,389 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: C
File: src/stackwalk.c
PR Title: Print task backtraces on sigquit
BEFORE CODE: JL_DLLEXPORT void jl_gdblookup(void* ip)
{
jl_print_native_codeloc((uintptr_t)ip);
}
// Print backtrace for current exception in catch block
JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEP... | ```suggestion
jl_task_t *ct = jl_get_current_task();
``` | 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_print_native_codeloc((uintptr_t)ip);
}
// Print backtrace for current exception in catch block
JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT
{
jl_task_t *ct = jl_current_task;
if (ct->ptls == NULL)
return;
jl_excstack_t *s = ct->excstack;
if (!s)
return;
size_t i, bt_si... | ```suggestion
if (ct && ct->ptls != NULL) {
``` | jl_fprint_native_codeloc(ios_safe_stderr, (uintptr_t)ip);
}
// Print backtrace for current exception in catch block
JL_DLLEXPORT void jl_fprint_backtrace(ios_t *s) JL_NOTSAFEPOINT
{
jl_task_t *ct = jl_current_task;
if (ct->ptls == NULL)
return;
jl_excstack_t *stack = ct->excstack;
if (!stac... | @@ -1387,11 +1387,19 @@ JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT
// Print backtrace for specified task to jl_safe_printf stderr
JL_DLLEXPORT void jlbacktracet(jl_task_t *t) JL_NOTSAFEPOINT
{
+ jl_bt_element_t *bt_data;
jl_task_t *ct = jl_current_task;
- jl_ptls_t ptls = ct->ptls;
- ptls->bt_... | src/stackwalk.c | 26 | C | 0.714 | suggestion | 53 | 51 | 51 | false | Print task backtraces on sigquit | 59,389 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: C
File: src/stackwalk.c
PR Title: Print task backtraces on sigquit
BEFORE CODE: jl_print_native_codeloc((uintptr_t)ip);
}
// Print backtrace for current exception in catch block
JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT
{
jl_task_t *ct = jl_current_task;... | ```suggestion
if (ct && ct->ptls != NULL) {
``` | 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. |
# get the homedir, as reported by uv_os_get_passwd, as used by jl_format_filename
try
homedir()
catch ex
(ex isa Base.IOError && ex.code == Base.UV_ENOENT) || rethrow(ex)
""
end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
... | ```suggestion
write(stdout, "r")
eof(stdout)
``` | # get the homedir, as reported by uv_os_get_passwd, as used by jl_format_filename
try
homedir()
catch ex
(ex isa Base.IOError && ex.code == Base.UV_ENOENT) || rethrow(ex)
""
end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
... | @@ -74,6 +74,31 @@ let
@test format_filename("%a%%b") == "a%b"
end
+if Sys.isunix()
+ @testset "SIGQUIT prints task backtraces" begin
+ script = """
+ mutable struct RLimit
+ cur::Int64
+ max::Int64
+ end
+ const RLIMIT_CORE = 4 # from /us... | test/cmdlineargs.jl | 26 | Julia | 0.571 | suggestion | 75 | 51 | 51 | false | Print task backtraces on sigquit | 59,389 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: Julia
File: test/cmdlineargs.jl
PR Title: Print task backtraces on sigquit
BEFORE CODE: # get the homedir, as reported by uv_os_get_passwd, as used by jl_format_filename
try
homedir()
catch ex
(ex isa Base.IOError && ex.code ... | ```suggestion
write(stdout, "r")
eof(stdout)
``` | 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
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.gethostname()) ", fn)
@test format_filename("%a%%b") == "a%b"
end
if Sys.isunix()
@testset "SIGQUIT prints task backtraces" begin
... | ```suggestion
p = open(pipeline(`$exename -e $script`, "r"), stderr=errp)
@test read(p, UInt8) = UInt8('r')
``` | end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.gethostname()) ", fn)
@test format_filename("%a%%b") == "a%b"
end
if Sys.isunix()
@testset "SIGQUIT prints task backtraces" begin
... | @@ -74,6 +74,31 @@ let
@test format_filename("%a%%b") == "a%b"
end
+if Sys.isunix()
+ @testset "SIGQUIT prints task backtraces" begin
+ script = """
+ mutable struct RLimit
+ cur::Int64
+ max::Int64
+ end
+ const RLIMIT_CORE = 4 # from /us... | test/cmdlineargs.jl | 26 | Julia | 0.714 | suggestion | 130 | 51 | 51 | false | Print task backtraces on sigquit | 59,389 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: Julia
File: test/cmdlineargs.jl
PR Title: Print task backtraces on sigquit
BEFORE CODE: end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.getho... | ```suggestion
p = open(pipeline(`$exename -e $script`, "r"), stderr=errp)
@test read(p, UInt8) = UInt8('r')
``` | 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. |
catch ex
(ex isa Base.IOError && ex.code == Base.UV_ENOENT) || rethrow(ex)
""
end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.gethostname()) ", fn)
@tes... | ```suggestion
errp = IOBuffer()
```
(this was previously a data race, which made this test dangerous) | catch ex
(ex isa Base.IOError && ex.code == Base.UV_ENOENT) || rethrow(ex)
""
end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.gethostname()) ", fn)
@tes... | @@ -74,6 +74,31 @@ let
@test format_filename("%a%%b") == "a%b"
end
+if Sys.isunix()
+ @testset "SIGQUIT prints task backtraces" begin
+ script = """
+ mutable struct RLimit
+ cur::Int64
+ max::Int64
+ end
+ const RLIMIT_CORE = 4 # from /us... | test/cmdlineargs.jl | 26 | Julia | 0.714 | bug | 112 | 51 | 51 | false | Print task backtraces on sigquit | 59,389 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: Julia
File: test/cmdlineargs.jl
PR Title: Print task backtraces on sigquit
BEFORE CODE: catch ex
(ex isa Base.IOError && ex.code == Base.UV_ENOENT) || rethrow(ex)
""
end
end
@test startswith(fn, "a$hd ")
@test endswith(fn... | ```suggestion
errp = IOBuffer()
```
(this was previously a data race, which made this test dangerous) | 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
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.gethostname()) ", fn)
@test format_filename("%a%%b") == "a%b"
end
if Sys.isunix()
@testset "SIGQUIT prints task backtraces" begin
... | ```suggestion
p = open(pipeline(`$exename -e $script`, stderr=errp), "r")
``` | end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.gethostname()) ", fn)
@test format_filename("%a%%b") == "a%b"
end
if Sys.isunix()
@testset "SIGQUIT prints task backtraces" begin
... | @@ -74,6 +74,32 @@ let
@test format_filename("%a%%b") == "a%b"
end
+if Sys.isunix()
+ @testset "SIGQUIT prints task backtraces" begin
+ script = """
+ mutable struct RLimit
+ cur::Int64
+ max::Int64
+ end
+ const RLIMIT_CORE = 4 # from /us... | test/cmdlineargs.jl | 26 | Julia | 0.571 | suggestion | 87 | 51 | 51 | false | Print task backtraces on sigquit | 59,389 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: Julia
File: test/cmdlineargs.jl
PR Title: Print task backtraces on sigquit
BEFORE CODE: end
end
@test startswith(fn, "a$hd ")
@test endswith(fn, " z")
@test !occursin('%', fn)
@test occursin(" $(getpid()) ", fn)
@test occursin(" $(Libc.getho... | ```suggestion
p = open(pipeline(`$exename -e $script`, stderr=errp), "r")
``` | 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. |
#ifndef _OS_WINDOWS_
sigset_t sset;
sigemptyset(&sset);
// n.b. In `abort()`, Apple's libSystem "helpfully" blocks all signals
// on all threads but SIGABRT. But we also don't know what the thread
// was doing, so unblock all critical signals so that they will crash
// ha... | I must gripe that having this now conditionally smashing bt_data just 5 lines before we need to use it for useful fatal backtraces is very annoying | #ifndef _OS_WINDOWS_
sigset_t sset;
sigemptyset(&sset);
// n.b. In `abort()`, Apple's libSystem "helpfully" blocks all signals
// on all threads but SIGABRT. But we also don't know what the thread
// was doing, so unblock all critical signals so that they will crash
// ha... | @@ -639,6 +639,9 @@ void jl_fprint_critical_error(ios_t *s, int sig, int si_code, bt_context_t *cont
jl_safe_fprintf(s, "\n[%d] signal %d (%d): %s\n", getpid(), sig, si_code, strsignal(sig));
else
jl_safe_fprintf(s, "\n[%d] signal %d: %s\n", getpid(), sig, strsignal(sig));
+ if... | src/signal-handling.c | 26 | C | 0.429 | suggestion | 147 | 42 | 45 | false | Print task backtraces on sigquit | 59,389 | JuliaLang/julia | 35,573 | Julia | vtjnash | gbaraldi | Review this pull request change.
Language: C
File: src/signal-handling.c
PR Title: Print task backtraces on sigquit
BEFORE CODE: #ifndef _OS_WINDOWS_
sigset_t sset;
sigemptyset(&sset);
// n.b. In `abort()`, Apple's libSystem "helpfully" blocks all signals
// on all threads but SIGABR... | I must gripe that having this now conditionally smashing bt_data just 5 lines before we need to use it for useful fatal backtraces is very annoying | 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> g(x) = a[] + b[] + x;
julia> with(a=>10, b=>20) do
g(30)
end
60
julia> with(() -> a[] * b[], a=>3, b=>4)
12
```
"""
function with(f, pair::Pair{<:AbstractScopedValue}, rest::Pair{<:AbstractScopedValue}...)
@with(pair, rest..., f())
end
with(@nospecialize(f)) = f()
macro enter_scope(scope... | i suppose we should avoid "functor" here?
I suppose either
```suggestion
Create a function object that records the current dynamic scope, i.e. all current
`ScopedValue`s, along with `f`. When the function object is invoked, it runs `f`
in the recorded dynamic scope.
```
| julia> with(a=>10, b=>20) do
g(30)
end
60
julia> with(() -> a[] * b[], a=>3, b=>4)
12
```
"""
function with(f, pair::Pair{<:AbstractScopedValue}, rest::Pair{<:AbstractScopedValue}...)
@with(pair, rest..., f())
end
with(@nospecialize(f)) = f()
macro enter_scope(scope, expr)
Expr(:tryfinally, ... | @@ -327,4 +327,24 @@ function with(f, pair::Pair{<:AbstractScopedValue}, rest::Pair{<:AbstractScopedV
end
with(@nospecialize(f)) = f()
+macro enter_scope(scope, expr)
+ Expr(:tryfinally, esc(expr), nothing, :(Scope($(esc(scope))::Union{Nothing, Scope})))
+end
+
+"""
+ ScopedThunk(f)
+
+Create a functor that r... | base/scopedvalues.jl | 26 | Julia | 0.857 | suggestion | 280 | 38 | 36 | false | ScopedValues: add ScopedThunk | 59,402 | JuliaLang/julia | 35,573 | Julia | nickrobinson251 | kpamnany | Review this pull request change.
Language: Julia
File: base/scopedvalues.jl
PR Title: ScopedValues: add ScopedThunk
BEFORE CODE: julia> g(x) = a[] + b[] + x;
julia> with(a=>10, b=>20) do
g(30)
end
60
julia> with(() -> a[] * b[], a=>3, b=>4)
12
```
"""
function with(f, pair::Pair{<:AbstractScoped... | i suppose we should avoid "functor" here?
I suppose either
```suggestion
Create a function object that records the current dynamic scope, i.e. all current
`ScopedValue`s, along with `f`. When the function object is invoked, it runs `f`
in the recorded dynamic scope.
```
| 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. |
Meta.unescape(expr)
Peel away `:escape` expressions and redundant block expressions (see
[`unblock`](@ref)).
"""
function unescape(@nospecialize ex)
ex = unblock(ex)
while isexpr(ex, :escape) || isexpr(ex, :var"hygienic-scope")
ex = unblock(ex.args[1])
end
return ex
end
"""
Meta.reescap... | ```suggestion
next, ctx... = original_expr.args
return reescape(Expr(:var"hygienic-scope", unescaped_expr, ctx...), next)
```
(there is technically a third optional argument of the source location to mark for inlining of the location of the original call to the macro) | Meta.unescape(expr)
Peel away `:escape` expressions and redundant block expressions (see
[`unblock`](@ref)).
"""
function unescape(@nospecialize ex)
ex = unblock(ex)
while isexpr(ex, :escape) || isexpr(ex, :var"hygienic-scope")
ex = unblock(ex.args[1])
end
return ex
end
"""
Meta.reescap... | @@ -636,8 +636,11 @@ This is the inverse operation of [`unescape`](@ref) - if the original expression
was escaped, the unescaped expression is wrapped in `:escape` again.
"""
function reescape(@nospecialize(unescaped_expr), @nospecialize(original_expr))
- if isexpr(original_expr, :escape) || isexpr(original_expr,... | base/meta.jl | 26 | Julia | 0.786 | security | 288 | 40 | 40 | false | Fix rebasing bug for `Meta.reescape` | 59,409 | JuliaLang/julia | 35,573 | Julia | vtjnash | serenity4 | Review this pull request change.
Language: Julia
File: base/meta.jl
PR Title: Fix rebasing bug for `Meta.reescape`
BEFORE CODE: Meta.unescape(expr)
Peel away `:escape` expressions and redundant block expressions (see
[`unblock`](@ref)).
"""
function unescape(@nospecialize ex)
ex = unblock(ex)
while ise... | ```suggestion
next, ctx... = original_expr.args
return reescape(Expr(:var"hygienic-scope", unescaped_expr, ctx...), next)
```
(there is technically a third optional argument of the source location to mark for inlining of the location of the original call to the 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. |
using Test
const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FakePTYs.jl"))
import .Main.FakePTYs: with_fake_pty
@testset "Bad history file startup" begin
mktempdir() do tmpdir
# Create a... | ```suggestion
output = readuntil(ptm, "julia> ", keep=true)
println("====== subprocess output ======")
println(output)
println("====== end subprocess output ======")
``` | using Test
const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FakePTYs.jl"))
import .Main.FakePTYs: with_fake_pty
@testset "Bad history file startup" begin
mktempdir() do tmpdir
# Create a... | @@ -0,0 +1,71 @@
+# This file is a part of Julia. License is MIT: https://julialang.org/license
+
+# Test that interactive mode starts up without error when history file is bad
+
+using Test
+
+const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
+isdefined(Main, :FakePTYs) || @eval Main include(... | stdlib/REPL/test/bad_history_startup.jl | 26 | Julia | 0.786 | suggestion | 222 | 51 | 51 | false | Fix startup when history file is bad | 59,418 | JuliaLang/julia | 35,573 | Julia | IanButterworth | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/REPL/test/bad_history_startup.jl
PR Title: Fix startup when history file is bad
BEFORE CODE: using Test
const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PAT... | ```suggestion
output = readuntil(ptm, "julia> ", keep=true)
println("====== subprocess output ======")
println(output)
println("====== end subprocess output ======")
``` | 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. |
isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FakePTYs.jl"))
import .Main.FakePTYs: with_fake_pty
@testset "Bad history file startup" begin
mktempdir() do tmpdir
# Create a bad history file
hist_file = joinpath(tmpdir, "repl_history.jl")
write(... | ```suggestion
# println("====== subprocess output ======")
# println(output)
# println("====== end subprocess output ======")
```
| isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FakePTYs.jl"))
import .Main.FakePTYs: with_fake_pty
@testset "Bad history file startup" begin
mktempdir() do tmpdir
# Create a bad history file
hist_file = joinpath(tmpdir, "repl_history.jl")
write(... | @@ -0,0 +1,74 @@
+# This file is a part of Julia. License is MIT: https://julialang.org/license
+
+# Test that interactive mode starts up without error when history file is bad
+
+using Test
+
+const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
+isdefined(Main, :FakePTYs) || @eval Main include(... | stdlib/REPL/test/bad_history_startup.jl | 26 | Julia | 0.714 | suggestion | 166 | 51 | 51 | false | Fix startup when history file is bad | 59,418 | JuliaLang/julia | 35,573 | Julia | IanButterworth | IanButterworth | Review this pull request change.
Language: Julia
File: stdlib/REPL/test/bad_history_startup.jl
PR Title: Fix startup when history file is bad
BEFORE CODE: isdefined(Main, :FakePTYs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FakePTYs.jl"))
import .Main.FakePTYs: with_fake_pty
@testset "Bad h... | ```suggestion
# println("====== subprocess output ======")
# println(output)
# println("====== end subprocess output ======")
```
| 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. |
symdiff!(v::AbstractVector{T}, itrs...) where {T} =
_grow!(_shrink_filter!(symdiff!(Set{T}(), v, itrs...)), v, itrs)
function _shrink!(shrinker!::F, v::AbstractVector, itrs) where F
seen = Set{eltype(v)}()
filter!(_grow_filter!(seen), v)
shrinker!(seen, itrs...)
filter!(in(seen), v)
end
intersect... | Would this work? Possibly I'm misunderstanding something, but I don't see why is promotion necessary, given that `setdiff!` never adds elements to the set.
```suggestion
T = eltype(itr)
keep = setdiff!(Set{T}(itr), itrs...)
vectorfilter(T, _shrink_filter!(keep), itr)
``` |
symdiff!(v::AbstractVector{T}, itrs...) where {T} =
_grow!(_shrink_filter!(symdiff!(Set{T}(), v, itrs...)), v, itrs)
function _shrink!(shrinker!::F, v::AbstractVector, itrs) where F
seen = Set{eltype(v)}()
filter!(_grow_filter!(seen), v)
shrinker!(seen, itrs...)
filter!(in(seen), v)
end
intersect... | @@ -3133,14 +3133,17 @@ setdiff!( v::AbstractVector, itrs...) = _shrink!(setdiff!, v, itrs)
vectorfilter(T::Type, f, v) = T[x for x in v if f(x)]
-function _shrink(shrinker!::F, itr, itrs) where F
+function intersect(itr, itrs...)
T = promote_eltype(itr, itrs...)
- keep = shrinker!(Set{T}(itr), itrs...)
+... | base/array.jl | 26 | Julia | 0.929 | suggestion | 290 | 51 | 51 | false | setdiff preserves eltype | 59,439 | JuliaLang/julia | 35,573 | Julia | nsajko | adienes | Review this pull request change.
Language: Julia
File: base/array.jl
PR Title: setdiff preserves eltype
BEFORE CODE:
symdiff!(v::AbstractVector{T}, itrs...) where {T} =
_grow!(_shrink_filter!(symdiff!(Set{T}(), v, itrs...)), v, itrs)
function _shrink!(shrinker!::F, v::AbstractVector, itrs) where F
seen = ... | Would this work? Possibly I'm misunderstanding something, but I don't see why is promotion necessary, given that `setdiff!` never adds elements to the set.
```suggestion
T = eltype(itr)
keep = setdiff!(Set{T}(itr), itrs...)
vectorfilter(T, _shrink_filter!(keep), itr)
``` | 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. |
c = MPZ.scan0(x, 0)
c == -1 && throw(DomainError(x, "`x` must not be equal to -1"))
c
end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x, "`x` cannot be negative"))
c
end
# generic definition is not used to provide a better error message
function count_zeros(... | ```suggestion
# Assumes `x != 0`. Computes top_set_bit(abs(x)).
```
I know this is a common comment style in some packages but afaik it's not common in Base | c = MPZ.scan0(x, 0)
c == -1 && throw(DomainError(x, "`x` must not be equal to -1"))
c
end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x, "`x` cannot be negative"))
c
end
# generic definition is not used to provide a better error message
function count_zeros(... | @@ -605,10 +605,14 @@ Number of ones in the binary representation of abs(x).
"""
count_ones_abs(x::BigInt) = iszero(x) ? 0 : MPZ.mpn_popcount(x)
+"Assumes `x != 0`. Computes top_set_bit(abs(x))." | base/gmp.jl | 26 | Julia | 0.714 | suggestion | 161 | 51 | 51 | false | New `prod(::AbstractArray{BigInt})` implementation | 59,456 | JuliaLang/julia | 35,573 | Julia | adienes | LilithHafner | Review this pull request change.
Language: Julia
File: base/gmp.jl
PR Title: New `prod(::AbstractArray{BigInt})` implementation
BEFORE CODE: c = MPZ.scan0(x, 0)
c == -1 && throw(DomainError(x, "`x` must not be equal to -1"))
c
end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && th... | ```suggestion
# Assumes `x != 0`. Computes top_set_bit(abs(x)).
```
I know this is a common comment style in some packages but afaik it's not common 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. |
end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x, "`x` cannot be negative"))
c
end
# generic definition is not used to provide a better error message
function count_zeros(x::BigInt)
c = MPZ.popcount(~x)
c == -1 && throw(DomainError(x, "`x` must be negative"))
... | for `prod` it seems like we probably don't need to compute the size this accurately. We can probably just use `abs(x.size)` | end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x, "`x` cannot be negative"))
c
end
# generic definition is not used to provide a better error message
function count_zeros(x::BigInt)
c = MPZ.popcount(~x)
c == -1 && throw(DomainError(x, "`x` must be negative"))
... | @@ -605,10 +605,14 @@ Number of ones in the binary representation of abs(x).
"""
count_ones_abs(x::BigInt) = iszero(x) ? 0 : MPZ.mpn_popcount(x)
+"Assumes `x != 0`. Computes top_set_bit(abs(x))."
+function _top_set_bit(x::BigInt)
+ abs(x.size) * BITS_PER_LIMB - GC.@preserve x leading_zeros(unsafe_load(x.d, abs(x... | base/gmp.jl | 26 | Julia | 0.571 | suggestion | 123 | 51 | 51 | false | New `prod(::AbstractArray{BigInt})` implementation | 59,456 | JuliaLang/julia | 35,573 | Julia | oscardssmith | LilithHafner | Review this pull request change.
Language: Julia
File: base/gmp.jl
PR Title: New `prod(::AbstractArray{BigInt})` implementation
BEFORE CODE: end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x, "`x` cannot be negative"))
c
end
# generic definition is not used to provi... | for `prod` it seems like we probably don't need to compute the size this accurately. We can probably just use `abs(x.size)` | 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. |
powermod(x::Integer, p::Integer, m::BigInt) = powermod(big(x), big(p), m)
function gcdx(a::BigInt, b::BigInt)
g, s, t = MPZ.gcdext(a, b)
if t == 0
# work around a difference in some versions of GMP
if a == b
return g, t, s
elseif abs(a)==abs(b)
return g, t, -s
... | maybe add a fast path for `iszero(arr[i])` that skips all the multiplications? | g, s, t = MPZ.gcdext(a, b)
if t == 0
# work around a difference in some versions of GMP
if a == b
return g, t, s
elseif abs(a)==abs(b)
return g, t, -s
end
end
g, s, t
end
+(x::BigInt, y::BigInt, rest::BigInt...) = sum(tuple(x, y, rest...))
sum(arr... | @@ -680,24 +684,33 @@ sum(arr::Union{AbstractArray{BigInt}, Tuple{BigInt, Vararg{BigInt}}}) =
foldl(MPZ.add!, arr; init=BigInt(0))
function prod(arr::AbstractArray{BigInt})
- # compute first the needed number of bits for the result,
- # to avoid re-allocations;
- # GMP will always request n+m limbs for... | base/gmp.jl | 26 | Julia | 0.357 | question | 78 | 51 | 51 | false | New `prod(::AbstractArray{BigInt})` implementation | 59,456 | JuliaLang/julia | 35,573 | Julia | oscardssmith | LilithHafner | Review this pull request change.
Language: Julia
File: base/gmp.jl
PR Title: New `prod(::AbstractArray{BigInt})` implementation
BEFORE CODE:
powermod(x::Integer, p::Integer, m::BigInt) = powermod(big(x), big(p), m)
function gcdx(a::BigInt, b::BigInt)
g, s, t = MPZ.gcdext(a, b)
if t == 0
# work aro... | maybe add a fast path for `iszero(arr[i])` that skips all the multiplications? | 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
# Check if method1 is more specific than method2 via the interference graph
function method_morespecific_via_interferences(method1::Method, method2::Method)
if method1 === method2
return false
end
# Check direct interferences first
if method_in_interferences(method2, method1)
retur... | Let's delete those unnecessary comments. We should probably explicitly declare the preference for self-explaining code over randomly scattered commets. | end
# Check if method1 is more specific than method2 via the interference graph
function method_morespecific_via_interferences(method1::Method, method2::Method)
if method1 === method2
return false
end
# Check direct interferences first
if method_in_interferences(method2, method1)
retur... | @@ -426,35 +426,52 @@ function method_morespecific_via_interferences(method1::Method, method2::Method)
if method1 === method2
return false
end
- ms = method_in_interferences_recursive(method1, method2, IdSet{Method}())
- # slow check: @assert ms === morespecific(method1, method2) || typeinterse... | Compiler/src/reinfer.jl | 26 | Julia | 0.429 | suggestion | 151 | 51 | 51 | false | convert more recursive algorithms from stack to heap space (iterative) | 59,482 | JuliaLang/julia | 35,573 | Julia | aviatesk | vtjnash | Review this pull request change.
Language: Julia
File: Compiler/src/reinfer.jl
PR Title: convert more recursive algorithms from stack to heap space (iterative)
BEFORE CODE: end
# Check if method1 is more specific than method2 via the interference graph
function method_morespecific_via_interferences(method1::Method... | Let's delete those unnecessary comments. We should probably explicitly declare the preference for self-explaining code over randomly scattered commets. | 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
munmap((void *)data, len);
#endif
}
// From a shared library handle, verify consistency and return a jl_image_buf_t
static jl_image_buf_t get_image_buf(void *handle, int is_pkgimage)
{
// verify that the linker resolved the symbols in this image against ourselves (libjulia-internal)
void** (*get_jl_R... | Is this correct if the first word of the `jl_image_unpack` function body happens to be NULL? | munmap((void *)data, len);
#endif
}
// From a shared library handle, verify consistency and return a jl_image_buf_t
static jl_image_buf_t get_image_buf(void *handle, int is_pkgimage)
{
// verify that the linker resolved the symbols in this image against ourselves (libjulia-internal)
void** (*get_jl_RTLD_DE... | @@ -3722,19 +3721,17 @@ static jl_image_buf_t get_image_buf(void *handle, int is_pkgimage)
};
// verification passed, lookup the buffer pointers
- if (jl_system_image_size == 0 || is_pkgimage) {
+ if (jl_image_unpack == NULL || is_pkgimage) { | src/staticdata.c | 26 | C | 0.5 | question | 92 | 51 | 51 | false | Allow linking a system image with jl_image_unpack with libjulia | 59,498 | JuliaLang/julia | 35,573 | Julia | topolarity | xal-0 | Review this pull request change.
Language: C
File: src/staticdata.c
PR Title: Allow linking a system image with jl_image_unpack with libjulia
BEFORE CODE: #else
munmap((void *)data, len);
#endif
}
// From a shared library handle, verify consistency and return a jl_image_buf_t
static jl_image_buf_t get_image_bu... | Is this correct if the first word of the `jl_image_unpack` function body happens to be NULL? | 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 k - exponent_bias(T)
end
# Like exponent, but assumes the nothrow precondition. For
# internal use only. Could be written as
# @assume_effects :nothrow exponent()
# but currently this form is easier on the compiler.
function _exponent_finite_nonzero(x::T) where T<:IEEEFloat
# @precond :nothrow !isnan(x)... | is the compiler figurign out that d is a power of 2? | # Like exponent, but assumes the nothrow precondition. For
# internal use only. Could be written as
# @assume_effects :nothrow exponent()
# but currently this form is easier on the compiler.
function _exponent_finite_nonzero(x::T) where T<:IEEEFloat
# @precond :nothrow !isnan(x) && !isinf(x) && !iszero(x)
xs = ... | @@ -980,6 +980,26 @@ function _exponent_finite_nonzero(x::T) where T<:IEEEFloat
return k - exponent_bias(T)
end
+function _ilog2_step(y::T, d::T, s) where {T<:Integer}
+ if fld(y, d) ≥ d
+ y, n = _ilog2_step(y, d*d, s+s)
+ else
+ n = 0
+ end
+ if y ≥ d
+ y = fld(y, d) | base/math.jl | 26 | Julia | 0.214 | question | 52 | 51 | 51 | false | fix `exponent` and `top_set_bit` fallbacks for `Integer` | 59,508 | JuliaLang/julia | 35,573 | Julia | oscardssmith | adienes | Review this pull request change.
Language: Julia
File: base/math.jl
PR Title: fix `exponent` and `top_set_bit` fallbacks for `Integer`
BEFORE CODE: return k - exponent_bias(T)
end
# Like exponent, but assumes the nothrow precondition. For
# internal use only. Could be written as
# @assume_effects :nothrow exp... | is the compiler figurign out that d is a power of 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. |
c == -1 && throw(DomainError(x, "`x` must not be equal to -1"))
c
end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x, "`x` cannot be negative"))
c
end
# generic definition is not used to provide a better error message
function count_zeros(x::BigInt)
c = MPZ.p... | Isn't this function equivalent to `MPZ.sizeinbase(x, 2)`? The [MPZ docs](https://gmplib.org/manual/Miscellaneous-Integer-Functions#index-mpz_005fsizeinbase) say
> It will be noted that mpz_sizeinbase(op,2) can be used to locate the most significant 1 bit in op, counting from 1. | c == -1 && throw(DomainError(x, "`x` must not be equal to -1"))
c
end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x, "`x` cannot be negative"))
c
end
# generic definition is not used to provide a better error message
function count_zeros(x::BigInt)
c = MPZ.p... | @@ -605,10 +605,18 @@ Number of ones in the binary representation of abs(x).
"""
count_ones_abs(x::BigInt) = iszero(x) ? 0 : MPZ.mpn_popcount(x)
+_bit_magnitude(x::BigInt) = x.size * sizeof(Limb) << 3 - leading_zeros(GC.@preserve x unsafe_load(x.d, x.size)) | base/gmp.jl | 26 | Julia | 0.643 | question | 280 | 51 | 51 | false | fix `exponent` and `top_set_bit` fallbacks for `Integer` | 59,508 | JuliaLang/julia | 35,573 | Julia | barucden | adienes | Review this pull request change.
Language: Julia
File: base/gmp.jl
PR Title: fix `exponent` and `top_set_bit` fallbacks for `Integer`
BEFORE CODE: c == -1 && throw(DomainError(x, "`x` must not be equal to -1"))
c
end
function count_ones(x::BigInt)
c = MPZ.popcount(x)
c == -1 && throw(DomainError(x... | Isn't this function equivalent to `MPZ.sizeinbase(x, 2)`? The [MPZ docs](https://gmplib.org/manual/Miscellaneous-Integer-Functions#index-mpz_005fsizeinbase) say
> It will be noted that mpz_sizeinbase(op,2) can be used to locate the most significant 1 bit in op, counting from 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. |
show_type(io, alg)
print(io, '(')
for (i, name) in enumerate(fieldnames(typeof(alg)))
arg = getproperty(alg, name)
i > 1 && print(io, ',')
if arg isa Algorithm
println(io)
print_tree(io, arg, cols+1)
else
i > 1 && print(io, ' ')
... | Documenting `rev::Bool=false` is a lie, but it is a pretty reasonable lie to lie. `rev::Bool` is the API we want, `rev::Union{Bool, Nothing}=nothing` where `nothing` is an alias for `false` is a cludgy performance workaround that could hopefully someday (maybe already) be removed when constant propagation is sufficient... | show_type(io, alg)
print(io, '(')
for (i, name) in enumerate(fieldnames(typeof(alg)))
arg = getproperty(alg, name)
i > 1 && print(io, ',')
if arg isa Algorithm
println(io)
print_tree(io, arg, cols+1)
else
i > 1 && print(io, ' ')
... | @@ -1623,7 +1623,7 @@ defalg(v::AbstractArray{Union{}}) = DEFAULT_UNSTABLE # for method disambiguation
defalg(v) = DEFAULT_STABLE
"""
- sort!(v; alg::Base.Sort.Algorithm=Base.Sort.defalg(v), lt=isless, by=identity, rev::Bool=false, order::Base.Order.Ordering=Base.Order.Forward)
+ sort!(v; alg::Base.Sort.Algor... | base/sort.jl | 26 | Julia | 0.786 | performance | 420 | 51 | 51 | false | fix several minor issues in docstrings and comments | 59,531 | JuliaLang/julia | 35,573 | Julia | LilithHafner | adienes | Review this pull request change.
Language: Julia
File: base/sort.jl
PR Title: fix several minor issues in docstrings and comments
BEFORE CODE: show_type(io, alg)
print(io, '(')
for (i, name) in enumerate(fieldnames(typeof(alg)))
arg = getproperty(alg, name)
i > 1 && print(io, ',')
... | Documenting `rev::Bool=false` is a lie, but it is a pretty reasonable lie to lie. `rev::Bool` is the API we want, `rev::Union{Bool, Nothing}=nothing` where `nothing` is an alias for `false` is a cludgy performance workaround that could hopefully someday (maybe already) be removed when constant propagation is sufficient... | 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 length(parsed) >= 1 && isa(parsed[1], Tuple{Cmd})
cmd = (parsed[1]::Tuple{Cmd})[1]
(ignorestatus, flags, env, dir, cpus, uid, gid) = (cmd.ignorestatus, cmd.flags, cmd.env, cmd.dir, cmd.cpus, cmd.uid, cmd.gid)
append!(args, cmd.exec)
for arg in tail(parsed)
append!(args... | ```suggestion
Similar to ``` `str` ```, generate a `Cmd` from the `str` string which represents the shell command(s) to be executed.
``` | if length(parsed) >= 1 && isa(parsed[1], Tuple{Cmd})
cmd = (parsed[1]::Tuple{Cmd})[1]
(ignorestatus, flags, env, dir, cpus, uid, gid) = (cmd.ignorestatus, cmd.flags, cmd.env, cmd.dir, cmd.cpus, cmd.uid, cmd.gid)
append!(args, cmd.exec)
for arg in tail(parsed)
append!(args... | @@ -562,7 +562,7 @@ end
"""
@cmd str
-Similar to ``` `str` ```, generate a `Cmd` from the `str` string which represents the shell command(s) to be executed.
+Similar to `` `str` ``, generate a `Cmd` from the `str` string which represents the shell command(s) to be executed. | base/cmd.jl | 26 | Julia | 0.714 | suggestion | 138 | 43 | 43 | false | fix several minor issues in docstrings and comments | 59,531 | JuliaLang/julia | 35,573 | Julia | adienes | adienes | Review this pull request change.
Language: Julia
File: base/cmd.jl
PR Title: fix several minor issues in docstrings and comments
BEFORE CODE: if length(parsed) >= 1 && isa(parsed[1], Tuple{Cmd})
cmd = (parsed[1]::Tuple{Cmd})[1]
(ignorestatus, flags, env, dir, cpus, uid, gid) = (cmd.ignorestatus,... | ```suggestion
Similar to ``` `str` ```, generate a `Cmd` from the `str` string which represents the shell command(s) to be executed.
``` | 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. |
@inbounds _unsetindex!(a, j)
end
elseif !prefer_start && memlen >= newmemlen
unsafe_copyto!(mem, offset - 1 + delta + i, mem, offset - 1 + i, len - i + 1)
for j in i:i+delta-1
@inbounds _unsetindex!(a, j)
end
else
# since we will allocate the array... | If it has to be formatted like this anyway, it feels a normal `if end` would work better. | @inbounds _unsetindex!(a, j)
end
elseif !prefer_start && memlen >= newmemlen
unsafe_copyto!(mem, offset - 1 + delta + i, mem, offset - 1 + i, len - i + 1)
for j in i:i+delta-1
@inbounds _unsetindex!(a, j)
end
else
# since we will allocate the array... | @@ -1264,7 +1264,10 @@ end
function _deletebeg!(a::Vector, delta::Integer)
delta = Int(delta)
len = length(a)
- 0 <= delta <= len || throw(ArgumentError("_deletebeg! requires delta in 0:length(a)"))
+ # See comment in _deleteend!
+ unsigned(delta) > unsigned(len) && throw( | base/array.jl | 26 | Julia | 0.429 | style | 89 | 51 | 51 | false | Help compiler know integer bounds in vector resizing ops | 59,540 | JuliaLang/julia | 35,573 | Julia | KristofferC | jakobnissen | Review this pull request change.
Language: Julia
File: base/array.jl
PR Title: Help compiler know integer bounds in vector resizing ops
BEFORE CODE: @inbounds _unsetindex!(a, j)
end
elseif !prefer_start && memlen >= newmemlen
unsafe_copyto!(mem, offset - 1 + delta + i, mem, offset - ... | If it has to be formatted like this anyway, it feels a normal `if end` would work 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. |
stmt_val = LiftedValue(lifted_philikes[reverse_mapping[stmt_val]].ssa)
else
error()
end
return Pair{Any, PhiNest}(stmt_val, PhiNest(visited_philikes, lifted_philikes, lifted_leaves, reverse_mapping, walker_callback))
end
function lift_apply_args!(compact::IncrementalCompact, idx::Int, stmt... | ```suggestion
if 0 < tuple_length <= tuple_length && !isvarargtype(arg_type.parameters[end]) # reasonable limit
``` | stmt_val = LiftedValue(lifted_philikes[reverse_mapping[stmt_val]].ssa)
else
error()
end
return Pair{Any, PhiNest}(stmt_val, PhiNest(visited_philikes, lifted_philikes, lifted_leaves, reverse_mapping, walker_callback))
end
function lift_apply_args!(compact::IncrementalCompact, idx::Int, stmt... | @@ -874,6 +874,49 @@ function perform_lifting!(compact::IncrementalCompact,
return Pair{Any, PhiNest}(stmt_val, PhiNest(visited_philikes, lifted_philikes, lifted_leaves, reverse_mapping, walker_callback))
end
+function lift_apply_args!(compact::IncrementalCompact, idx::Int, stmt::Expr, 𝕃ₒ::AbstractLattice)
+ ... | Compiler/src/ssair/passes.jl | 26 | Julia | 0.857 | suggestion | 133 | 51 | 51 | false | optimizations: better modeling and codegen for apply and svec calls | 59,548 | JuliaLang/julia | 35,573 | Julia | aviatesk | vtjnash | Review this pull request change.
Language: Julia
File: Compiler/src/ssair/passes.jl
PR Title: optimizations: better modeling and codegen for apply and svec calls
BEFORE CODE: stmt_val = LiftedValue(lifted_philikes[reverse_mapping[stmt_val]].ssa)
else
error()
end
return Pair{Any, PhiNest... | ```suggestion
if 0 < tuple_length <= tuple_length && !isvarargtype(arg_type.parameters[end]) # reasonable limit
``` | 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 :other
else
a = ex.args[1]
if a isa String
return fl_incomplete_tag(a)::Symbol
else
return incomplete_tag(a)::Symbol
end
end
end
incomplete_tag(exc::Meta.ParseError) = incomplete_tag(exc.detail)
function exec_options(opts)
startup ... | If it’s already `:full` I guess we shouldn’t downgrade it? | return :other
else
a = ex.args[1]
if a isa String
return fl_incomplete_tag(a)::Symbol
else
return incomplete_tag(a)::Symbol
end
end
end
incomplete_tag(exc::Meta.ParseError) = incomplete_tag(exc.detail)
function exec_options(opts)
startup ... | @@ -236,6 +236,20 @@ function exec_options(opts)
global have_color = colored_text(opts)
global is_interactive = (opts.isinteractive != 0)
+ # Enable verbose debugging options when requested by other frameworks
+ debug_env_vars = (
+ "RUNNER_DEBUG", # github actions when UI "debug logging"... | base/client.jl | 26 | Julia | 0.429 | question | 58 | 51 | 51 | false | Enable verbose debugging when github actions etc. requests it | 59,551 | JuliaLang/julia | 35,573 | Julia | ericphanson | IanButterworth | Review this pull request change.
Language: Julia
File: base/client.jl
PR Title: Enable verbose debugging when github actions etc. requests it
BEFORE CODE: return :other
else
a = ex.args[1]
if a isa String
return fl_incomplete_tag(a)::Symbol
else
return inc... | If it’s already `:full` I guess we shouldn’t downgrade 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. |
jl_init_threading();
jl_init_threadinginfra();
if (jl_options.handle_signals == JL_OPTIONS_HANDLE_SIGNALS_ON)
jl_install_default_signal_handlers();
jl_gc_init();
arraylist_new(&jl_linkage_blobs, 0);
arraylist_new(&jl_image_relocs, 0);
arraylist_new(&jl_top_mods, 0);
arraylist_n... | The ordering before seems quite intentional since `jl_init_root_task` uses `jl_nothing`.
So now the root task is storing an uninitialized pointer in places and later we use pointer identity checks "val == jl_nothing". | jl_init_threading();
jl_init_threadinginfra();
if (jl_options.handle_signals == JL_OPTIONS_HANDLE_SIGNALS_ON)
jl_install_default_signal_handlers();
jl_gc_init();
arraylist_new(&jl_linkage_blobs, 0);
arraylist_new(&jl_image_relocs, 0);
arraylist_new(&jl_top_mods, 0);
arraylist_n... | @@ -775,13 +775,13 @@ JL_DLLEXPORT void jl_init_(jl_image_buf_t sysimage)
// enable before creating the root task so it gets timings too.
jl_atomic_fetch_add(&jl_task_metrics_enabled, 1);
}
+ // warning: this changes `jl_current_task`, so be careful not to call that from this function
+ jl_... | src/init.c | 26 | C | 0.643 | suggestion | 221 | 40 | 40 | false | Adding `ptls` argument to `permobj` | 59,555 | JuliaLang/julia | 35,573 | Julia | vchuravy | udesou | Review this pull request change.
Language: C
File: src/init.c
PR Title: Adding `ptls` argument to `permobj`
BEFORE CODE: jl_init_threading();
jl_init_threadinginfra();
if (jl_options.handle_signals == JL_OPTIONS_HANDLE_SIGNALS_ON)
jl_install_default_signal_handlers();
jl_gc_init();
arr... | The ordering before seems quite intentional since `jl_init_root_task` uses `jl_nothing`.
So now the root task is storing an uninitialized pointer in places and later we use pointer identity checks "val == jl_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. |
return Base.get_world_counter()
end
let llvm = sprint(code_llvm, world_counter, ())
# check that we got a reasonable value for the world age
@test (world_counter() != 0) && (world_counter() != -1)
# no call to the runtime should be left over
@test !occursin("call i64", llvm)
# the world age shou... | An equivalent C program works:
```julia
julia> cc = `cc`;
julia> program = raw"""
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
void *h = dlopen("./libccalltest.so", RTLD_LAZY);
if (!h) {
fprintf(s... | return Base.get_world_counter()
end
let llvm = sprint(code_llvm, world_counter, ())
# check that we got a reasonable value for the world age
@test (world_counter() != 0) && (world_counter() != -1)
# no call to the runtime should be left over
@test !occursin("call i64", llvm)
# the world age shou... | @@ -1981,8 +1981,6 @@ let llvm = sprint(code_llvm, gc_safe_ccall, ())
end
@testset "jl_dlfind and dlsym" begin
- # We shouldn't be able to call libc functions through libccalltest
- @test_throws ErrorException ccall((:sqrt, libccalltest), Cdouble, (Cdouble,), 2.0) | test/ccall.jl | 26 | Julia | 1 | bug | 1,503 | 51 | 51 | false | Use jl_dlsym with search_deps=1 for ccalls | 59,560 | JuliaLang/julia | 35,573 | Julia | giordano | xal-0 | Review this pull request change.
Language: Julia
File: test/ccall.jl
PR Title: Use jl_dlsym with search_deps=1 for ccalls
BEFORE CODE: return Base.get_world_counter()
end
let llvm = sprint(code_llvm, world_counter, ())
# check that we got a reasonable value for the world age
@test (world_counter() != 0)... | An equivalent C program works:
```julia
julia> cc = `cc`;
julia> program = raw"""
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
void *h = dlopen("./libccalltest.so", RTLD_LAZY);
if (!h) {
fprintf(s... | 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
# RUN: julia --startup-file=no --check-bounds=yes %s %t -O
# RUN: cat %t/* | FileCheck %s
include(joinpath("..", "testhelpers", "llvmpasses.jl"))
# Test for GenericMemoryRef address space bug
# Issue: stores incorrectly use addrspace(10) in... | ```suggestion
emit(bf, Int, Vector{Float64})
``` | # This file is a part of Julia. License is MIT: https://julialang.org/license
# RUN: julia --startup-file=no --check-bounds=yes %s %t -O
# RUN: cat %t/* | FileCheck %s
include(joinpath("..", "testhelpers", "llvmpasses.jl"))
# Test for GenericMemoryRef address space bug
# Issue: stores incorrectly use addrspace(10) in... | @@ -0,0 +1,21 @@
+# This file is a part of Julia. License is MIT: https://julialang.org/license
+# RUN: julia --startup-file=no --check-bounds=yes %s %t -O
+# RUN: cat %t/* | FileCheck %s
+
+include(joinpath("..", "testhelpers", "llvmpasses.jl"))
+
+# Test for GenericMemoryRef address space bug
+# Issue: stores incorre... | test/llvmpasses/memoryref-addrspace.jl | 21 | Julia | 0.571 | suggestion | 50 | 22 | 22 | false | add GenericMemoryRef address space regression test | 59,568 | JuliaLang/julia | 35,573 | Julia | vtjnash | fjralf | Review this pull request change.
Language: Julia
File: test/llvmpasses/memoryref-addrspace.jl
PR Title: add GenericMemoryRef address space regression test
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
# RUN: julia --startup-file=no --check-bounds=yes %s %t -O
# RUN: cat ... | ```suggestion
emit(bf, Int, Vector{Float64})
``` | 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
# macro wrappers for various reflection functions
using Base: insert!, replace_ref_begin_end!,
infer_return_type, infer_exception_type, infer_effects, code_ircode, isexpr
# defined in Base so it's possible to time all imports, includin... | Can you explain more about this ambiguity?
`typeof` should never yield a (naked) `Vararg{...}` afaik | # This file is a part of Julia. License is MIT: https://julialang.org/license
# macro wrappers for various reflection functions
using Base: insert!, replace_ref_begin_end!,
infer_return_type, infer_exception_type, infer_effects, code_ircode, isexpr
# defined in Base so it's possible to time all imports, includin... | @@ -9,8 +9,34 @@ using Base: insert!, replace_ref_begin_end!,
# via. `Base.@time_imports` etc.
import Base: @time_imports, @trace_compile, @trace_dispatch
-typesof_expr(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:(Tuple{$(Any[esc(reescape(get_typeof, a)) for a in args]...... | stdlib/InteractiveUtils/src/macros.jl | 24 | Julia | 0.714 | suggestion | 101 | 49 | 49 | false | InteractiveUtils: Support unannotated values after `Vararg` type annotation | 59,594 | JuliaLang/julia | 35,573 | Julia | topolarity | serenity4 | Review this pull request change.
Language: Julia
File: stdlib/InteractiveUtils/src/macros.jl
PR Title: InteractiveUtils: Support unannotated values after `Vararg` type annotation
BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license
# macro wrappers for various reflection funct... | Can you explain more about this ambiguity?
`typeof` should never yield a (naked) `Vararg{...}` afaik | 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. |
infer_return_type, infer_exception_type, infer_effects, code_ircode, isexpr
# defined in Base so it's possible to time all imports, including InteractiveUtils and its deps
# via. `Base.@time_imports` etc.
import Base: @time_imports, @trace_compile, @trace_dispatch
typesof_expr(args::Vector{Any}, where_params::Uni... | Looks like these are unused now? | infer_return_type, infer_exception_type, infer_effects, code_ircode, isexpr
# defined in Base so it's possible to time all imports, including InteractiveUtils and its deps
# via. `Base.@time_imports` etc.
import Base: @time_imports, @trace_compile, @trace_dispatch
typesof_expr(args::Vector{Any}, where_params::Uni... | @@ -9,8 +9,26 @@ using Base: insert!, replace_ref_begin_end!,
# via. `Base.@time_imports` etc.
import Base: @time_imports, @trace_compile, @trace_dispatch
-typesof_expr(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:(Tuple{$(Any[esc(reescape(get_typeof, a)) for a in args]...... | stdlib/InteractiveUtils/src/macros.jl | 26 | Julia | 0.143 | question | 32 | 51 | 51 | false | InteractiveUtils: Support unannotated values after `Vararg` type annotation | 59,594 | JuliaLang/julia | 35,573 | Julia | topolarity | serenity4 | Review this pull request change.
Language: Julia
File: stdlib/InteractiveUtils/src/macros.jl
PR Title: InteractiveUtils: Support unannotated values after `Vararg` type annotation
BEFORE CODE: infer_return_type, infer_exception_type, infer_effects, code_ircode, isexpr
# defined in Base so it's possible to time ... | Looks like these are unused now? | 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. |
typesof_expr_unescaped(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:($make_tuple_type(Any[$(Any[reescape(get_typeof, a) for a in args]...)])), where_params)
function make_tuple_type(types::Vector{Any})
vararg = -1
for i in eachindex(types)
i == 1 && continue #... | Not sure if we need to add more conditions in there. That seems to do the trick for most cases. | typesof_expr_unescaped(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:($make_tuple_type(Any[$(Any[reescape(get_typeof, a) for a in args]...)])), where_params)
function make_tuple_type(types::Vector{Any})
vararg = -1
for i in eachindex(types)
i == 1 && continue #... | @@ -9,8 +9,33 @@ using Base: insert!, replace_ref_begin_end!,
# via. `Base.@time_imports` etc.
import Base: @time_imports, @trace_compile, @trace_dispatch
-typesof_expr(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:(Tuple{$(Any[esc(reescape(get_typeof, a)) for a in args]...... | stdlib/InteractiveUtils/src/macros.jl | 26 | Julia | 0.214 | suggestion | 95 | 51 | 51 | false | InteractiveUtils: Support unannotated values after `Vararg` type annotation | 59,594 | JuliaLang/julia | 35,573 | Julia | serenity4 | serenity4 | Review this pull request change.
Language: Julia
File: stdlib/InteractiveUtils/src/macros.jl
PR Title: InteractiveUtils: Support unannotated values after `Vararg` type annotation
BEFORE CODE: typesof_expr_unescaped(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:($make_tuple_... | Not sure if we need to add more conditions in there. That seems to do the trick for most cases. | 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. |
typesof_expr_unescaped(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:($make_tuple_type(Any[$(Any[reescape(get_typeof, a) for a in args]...)])), where_params)
function make_tuple_type(types::Vector{Any})
vararg = -1
for i in eachindex(types)
i == 1 && continue #... | ```suggestion
skip_type_check(@nospecialize(T)) = Core.has_free_typevars(T)
```
I believe this case is already covered for you:
```julia
julia> Core.has_free_typevars(Core.TypeVar(:X))
true
``` | typesof_expr_unescaped(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:($make_tuple_type(Any[$(Any[reescape(get_typeof, a) for a in args]...)])), where_params)
function make_tuple_type(types::Vector{Any})
vararg = -1
for i in eachindex(types)
i == 1 && continue #... | @@ -9,8 +9,33 @@ using Base: insert!, replace_ref_begin_end!,
# via. `Base.@time_imports` etc.
import Base: @time_imports, @trace_compile, @trace_dispatch
-typesof_expr(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:(Tuple{$(Any[esc(reescape(get_typeof, a)) for a in args]...... | stdlib/InteractiveUtils/src/macros.jl | 26 | Julia | 0.929 | suggestion | 202 | 51 | 51 | false | InteractiveUtils: Support unannotated values after `Vararg` type annotation | 59,594 | JuliaLang/julia | 35,573 | Julia | topolarity | serenity4 | Review this pull request change.
Language: Julia
File: stdlib/InteractiveUtils/src/macros.jl
PR Title: InteractiveUtils: Support unannotated values after `Vararg` type annotation
BEFORE CODE: typesof_expr_unescaped(args::Vector{Any}, where_params::Union{Nothing, Vector{Any}} = nothing) = rewrap_where(:($make_tuple_... | ```suggestion
skip_type_check(@nospecialize(T)) = Core.has_free_typevars(T)
```
I believe this case is already covered for you:
```julia
julia> Core.has_free_typevars(Core.TypeVar(:X))
true
``` | 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{}")
@noinline _invalid_base(base) = throw(ArgumentError("invalid base: base must be 2 ≤ base ≤ 62, got $base"))
@noinline _invalid_dig... | ```suggestion
codepoint - UInt8('A') + UInt8(10) # + 10 for the 10 digits
```
Given that the comment is referring to "10" and the other UInt8s around here are expressed as conversion from more semantically clear types. | 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
@noinl... | @@ -38,14 +38,42 @@ 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.929 | suggestion | 229 | 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 a... | ```suggestion
codepoint - UInt8('A') + UInt8(10) # + 10 for the 10 digits
```
Given that the comment is referring to "10" and the other UInt8s around here are expressed as conversion from more semantically clear types. | 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. |
```jldoctest
julia> parse(Int, "1234")
1234
julia> parse(Int, "1234", base = 5)
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...) = erro... | TBH I find this style more clear than the style introduced in this PR | ```jldoctest
julia> parse(Int, "1234")
1234
julia> parse(Int, "1234", base = 5)
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...) = erro... | @@ -38,14 +38,42 @@ 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.214 | style | 69 | 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: ```jldoctest
julia> parse(Int, "1234")
1234
julia> parse(Int, "1234", base = 5)
194
julia> parse(Int, "afc", base = 16)
2812
julia> parse(Float64, "1.2e-3")
0.0012
j... | TBH I find this style more clear than the style introduced in this PR | 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. |
# Examples
```jldoctest
julia> parse(Int, "1234")
1234
julia> parse(Int, "1234", base = 5)
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... | These are weirdly inconsistent? | # Examples
```jldoctest
julia> parse(Int, "1234")
1234
julia> parse(Int, "1234", base = 5)
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... | @@ -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.071 | question | 31 | 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: # Examples
```jldoctest
julia> parse(Int, "1234")
1234
julia> parse(Int, "1234", base = 5)
194
julia> parse(Int, "afc", base = 16)
2812
julia> parse(Float64, "1.2e-3"... | These are weirdly inconsistent? | 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.