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
mprotect_barrier_page = (_Atomic(uint64_t) *) mmap(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (mprotect_barrier_page == MAP_FAILED) { jl_safe_printf("fatal: failed to allocate barrier page.\n")...
This doesn't make sense (make readnone then mutate it). Perhaps you meant the other order?
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (mprotect_barrier_page == MAP_FAILED) { mprotect_barrier_page = NULL; result = pthread_mutex_unlock(&mprotect_barrier_lock); assert(result == 0); return 0; } result = mloc...
@@ -1274,3 +1274,128 @@ JL_DLLEXPORT int jl_repl_raise_sigtstp(void) { return raise(SIGTSTP); } + +// Linux and FreeBSD have compatible membarrier support +#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_) +#if defined(_OS_LINUX_) +# include <sys/syscall.h> +# if defined(__has_include) +# if __has_include(<linu...
src/signals-unix.c
26
C
0.214
question
90
51
51
false
threads: Implement asymmetric atomic fences
60,311
JuliaLang/julia
35,573
Julia
vtjnash
Keno
Review this pull request change. Language: C File: src/signals-unix.c PR Title: threads: Implement asymmetric atomic fences BEFORE CODE: mprotect_barrier_page = (_Atomic(uint64_t) *) mmap(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_...
This doesn't make sense (make readnone then mutate it). Perhaps you meant the other order?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
static _Atomic(enum membarrier_implementation) membarrier_impl = MEMBARRIER_IMPLEMENTATION_UNKNOWN; static enum membarrier_implementation jl_init_membarrier(void) { int ret = membarrier(MEMBARRIER_CMD_QUERY, 0); int needed = MEMBARRIER_CMD_PRIVATE_EXPEDITED | MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED; if (...
Claude: 1. Bug in jl_membarrier assertion (signals-unix.c:1394) ```assert(ret); // BUG: This asserts that ret is non-zero (failure)``` The assertion is inverted. It should be assert(ret == 0) to verify success, not assert(ret) which asserts the syscall failed.
MEMBARRIER_IMPLEMENTATION_UNKNOWN = 0, MEMBARRIER_IMPLEMENTATION_SYS_MEMBARRIER = 1, MEMBARRIER_IMPLEMENTATION_MPROTECT = 2, MEMBARRIER_IMPLEMENTATION_THREAD_SUSPEND = 3 }; static _Atomic(enum membarrier_implementation) membarrier_impl = MEMBARRIER_IMPLEMENTATION_UNKNOWN; // Linux and Fre...
@@ -1274,3 +1274,128 @@ JL_DLLEXPORT int jl_repl_raise_sigtstp(void) { return raise(SIGTSTP); } + +// Linux and FreeBSD have compatible membarrier support +#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_) +#if defined(_OS_LINUX_) +# include <sys/syscall.h> +# if defined(__has_include) +# if __has_include(<linu...
src/signals-unix.c
26
C
1
bug
268
34
51
false
threads: Implement asymmetric atomic fences
60,311
JuliaLang/julia
35,573
Julia
vtjnash
Keno
Review this pull request change. Language: C File: src/signals-unix.c PR Title: threads: Implement asymmetric atomic fences BEFORE CODE: static _Atomic(enum membarrier_implementation) membarrier_impl = MEMBARRIER_IMPLEMENTATION_UNKNOWN; static enum membarrier_implementation jl_init_membarrier(void) { int ret =...
Claude: 1. Bug in jl_membarrier assertion (signals-unix.c:1394) ```assert(ret); // BUG: This asserts that ret is non-zero (failure)``` The assertion is inverted. It should be assert(ret == 0) to verify success, not assert(ret) which asserts the syscall failed.
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 (membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0) == 0) { // working jl_atomic_store_relaxed(&membarrier_impl, MEMBARRIER_IMPLEMENTATION_SYS_MEMBARRIER); return MEMBARRIER_IMPLEMENTATION_SYS_MEMBARRIER; } } jl_init_mprotect_membarrier(); jl_atom...
Claude: 2. Missing jl_membarrier for non-Linux/FreeBSD Unix (signals-unix.c) The jl_membarrier function is only defined inside the `#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_)` block. Other Unix systems (like OpenBSD, NetBSD, Solaris) will have a missing symbol at link time. ```suggestion #else JL_...
// Linux and FreeBSD have compatible membarrier syscall support #if defined(_OS_LINUX_) # include <sys/syscall.h> # if defined(__NR_membarrier) enum membarrier_cmd { MEMBARRIER_CMD_QUERY = 0, MEMBARRIER_CMD_PRIVATE_EXPEDITED = (1 << 3), MEMBARRIER_CMD_REGISTER_PRIVATE_...
@@ -1274,3 +1274,128 @@ JL_DLLEXPORT int jl_repl_raise_sigtstp(void) { return raise(SIGTSTP); } + +// Linux and FreeBSD have compatible membarrier support +#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_) +#if defined(_OS_LINUX_) +# include <sys/syscall.h> +# if defined(__has_include) +# if __has_include(<linu...
src/signals-unix.c
26
C
1
performance
1,576
27
51
false
threads: Implement asymmetric atomic fences
60,311
JuliaLang/julia
35,573
Julia
vtjnash
Keno
Review this pull request change. Language: C File: src/signals-unix.c PR Title: threads: Implement asymmetric atomic fences BEFORE CODE: if (membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0) == 0) { // working jl_atomic_store_relaxed(&membarrier_impl, MEMBARRIER_IMPLEMENTATION...
Claude: 2. Missing jl_membarrier for non-Linux/FreeBSD Unix (signals-unix.c) The jl_membarrier function is only defined inside the `#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_)` block. Other Unix systems (like OpenBSD, NetBSD, Solaris) will have a missing symbol at link time. ```suggestion #else JL_...
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.
""" atomic_fence() = Core.Intrinsics.atomic_fence(:sequentially_consistent, :system) """ Threads.atomic_fence_light() This is a read-optimized sequential-consistency memory fence. On supported operating systems and architectures, this fence is cheaper than `Threads.atomic_fence()`, but synchronizes only with [`at...
Claude: 1. Missing export or public for new functions - atomic_fence_light and atomic_fence_heavy are defined but not added to the exports in base/atomics.jl.
""" atomic_fence() = Core.Intrinsics.atomic_fence(:sequentially_consistent, :system) """ Threads.atomic_fence_light() Insert the light side of an asymmetric sequential-consistency memory fence. Asymmetric memory fences are useful in scenarios where one side of the synchronization runs significantly less often tha...
@@ -329,4 +329,28 @@ fences should not be necessary in most cases. For further details, see LLVM's `fence` instruction. """ -atomic_fence() = Core.Intrinsics.atomic_fence(:sequentially_consistent) +atomic_fence() = Core.Intrinsics.atomic_fence(:sequentially_consistent, :system) + +""" + Threads.atomic_fence_ligh...
base/atomics.jl
26
Julia
0.357
suggestion
165
27
27
false
threads: Implement asymmetric atomic fences
60,311
JuliaLang/julia
35,573
Julia
vtjnash
Keno
Review this pull request change. Language: Julia File: base/atomics.jl PR Title: threads: Implement asymmetric atomic fences BEFORE CODE: """ atomic_fence() = Core.Intrinsics.atomic_fence(:sequentially_consistent, :system) """ Threads.atomic_fence_light() This is a read-optimized sequential-consistency memory...
Claude: 1. Missing export or public for new functions - atomic_fence_light and atomic_fence_heavy are defined but not added to the exports in base/atomics.jl.
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_fence(commbuf, i, count) end @test commbuf.correct[1] == true @test commbuf.correct[2] == true end test_fence() # Test asymmetric thread fences const asymmetric_test_count = 200_000 struct AsymmetricFenceTestData x::AtomicMemory{Int} y::AtomicMemory{Int} read_x::AtomicMemory{Int} ...
Claude suggests we make this ordering explicit ```suggestion @atomic :monotonic data.read_x[it] = @atomic :monotonic data.x[it] ```
test_fence(commbuf, i, count) end @test commbuf.correct[1] == true @test commbuf.correct[2] == true end test_fence() # Test asymmetric thread fences struct AsymmetricFenceTestData n::Int x::AtomicMemory{Int} y::AtomicMemory{Int} read_x::AtomicMemory{Int} read_y::AtomicMemory{Int...
@@ -464,6 +464,54 @@ function test_fence() end test_fence() +# Test asymmetric thread fences +const asymmetric_test_count = 200_000 +struct AsymmetricFenceTestData + x::AtomicMemory{Int} + y::AtomicMemory{Int} + read_x::AtomicMemory{Int} + read_y::AtomicMemory{Int} +end +function test_asymmetric_fence(d...
test/threads_exec.jl
26
Julia
0.714
suggestion
142
51
51
false
threads: Implement asymmetric atomic fences
60,311
JuliaLang/julia
35,573
Julia
vtjnash
Keno
Review this pull request change. Language: Julia File: test/threads_exec.jl PR Title: threads: Implement asymmetric atomic fences BEFORE CODE: test_fence(commbuf, i, count) end @test commbuf.correct[1] == true @test commbuf.correct[2] == true end test_fence() # Test asymmetric thread fences con...
Claude suggests we make this ordering explicit ```suggestion @atomic :monotonic data.read_x[it] = @atomic :monotonic data.x[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_DLLEXPORT int jl_repl_raise_sigtstp(void) { return raise(SIGTSTP); } // Linux and FreeBSD have compatible membarrier support #if defined(_OS_LINUX_) || defined(_OS_FREEBSD_) #if defined(_OS_LINUX_) # include <sys/syscall.h> # if defined(__has_include) # if __has_include(<linux/membarrier.h>) # includ...
```suggestion # define membarrier(...) (errno = ENOSYS; -1) ```
} JL_DLLEXPORT int jl_repl_raise_sigtstp(void) { return raise(SIGTSTP); } #if !defined(_OS_DARWIN_) // Thread suspension based membarrier fallback. // This is a sound but slow implementation that suspends and resumes each thread // to force them to execute memory barriers via the signal handling mechanism. // Thi...
@@ -1274,3 +1274,128 @@ JL_DLLEXPORT int jl_repl_raise_sigtstp(void) { return raise(SIGTSTP); } + +// Linux and FreeBSD have compatible membarrier support +#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_) +#if defined(_OS_LINUX_) +# include <sys/syscall.h> +# if defined(__has_include) +# if __has_include(<linu...
src/signals-unix.c
26
C
0.571
suggestion
73
51
51
false
threads: Implement asymmetric atomic fences
60,311
JuliaLang/julia
35,573
Julia
vtjnash
Keno
Review this pull request change. Language: C File: src/signals-unix.c PR Title: threads: Implement asymmetric atomic fences BEFORE CODE: } JL_DLLEXPORT int jl_repl_raise_sigtstp(void) { return raise(SIGTSTP); } // Linux and FreeBSD have compatible membarrier support #if defined(_OS_LINUX_) || defined(_OS_FREE...
```suggestion # define membarrier(...) (errno = ENOSYS; -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.
function test_asymmetric_fence(data, cond1, cond2, threadid) for i = 1:asymmetric_test_count test_asymmetric_fence(data, cond1, cond2, threadid, i) end end function test_asymmetric_fence() cond1 = Threads.Event(true) cond2 = Threads.Event(true) data = AsymmetricFenceTestData(AtomicMemory{Int...
From CI: ERROR: LoadError: syntax: unsupported `const` declaration on local variable around /cache/build/tester-amdci4-15/julialang/julia-master/julia-44b50e2b6a/share/julia/test/threads_exec.jl:468
function test_asymmetric_fence(data::AsymmetricFenceTestData, cond1, cond2, threadid) for i = 1:data.n test_asymmetric_fence(data, cond1, cond2, threadid, i) end end function test_asymmetric_fence() asymmetric_test_count = 200_000 cond1 = Threads.Event(true) cond2 = Threads.Event(true) d...
@@ -464,6 +464,54 @@ function test_fence() end test_fence() +# Test asymmetric thread fences +const asymmetric_test_count = 200_000 +struct AsymmetricFenceTestData + x::AtomicMemory{Int} + y::AtomicMemory{Int} + read_x::AtomicMemory{Int} + read_y::AtomicMemory{Int} +end +function test_asymmetric_fence(d...
test/threads_exec.jl
26
Julia
0.643
performance
198
51
51
false
threads: Implement asymmetric atomic fences
60,311
JuliaLang/julia
35,573
Julia
vtjnash
Keno
Review this pull request change. Language: Julia File: test/threads_exec.jl PR Title: threads: Implement asymmetric atomic fences BEFORE CODE: function test_asymmetric_fence(data, cond1, cond2, threadid) for i = 1:asymmetric_test_count test_asymmetric_fence(data, cond1, cond2, threadid, i) end end f...
From CI: ERROR: LoadError: syntax: unsupported `const` declaration on local variable around /cache/build/tester-amdci4-15/julialang/julia-master/julia-44b50e2b6a/share/julia/test/threads_exec.jl:468
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 _has_length_one(r::OrdinalRange) = first(r) == last(r) _has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) if lr != length(s) return false elseif iszero(lr) return true end yr, ys = iterate(r), iterate(s) while...
```suggestion (x1, x2) = last(zip(r1, r2)) ``` `min(lastindex(r1), lastindex(r2))` is not offset-safe note that `last(::Zip)` is fast whenever `Iterators.nth` is fast on the range (which it can be by calling `getindex`)
end _has_length_one(r::OrdinalRange) = first(r) == last(r) _has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) if lr != length(s) return false elseif iszero(lr) return true end yr, ys = iterate(r), iterate(s) while...
@@ -1168,6 +1168,17 @@ function ==(r::AbstractRange, s::AbstractRange) return true end +function cmp(r1::AbstractRange{T}, r2::AbstractRange{T}) where {T} + firstindex(r1) == firstindex(r2) || return cmp(firstindex(r1), firstindex(r2)) + (isempty(r1) || isempty(r2)) && return cmp(isempty(r2), isempty(r1))...
base/range.jl
26
Julia
0.786
suggestion
233
51
51
false
Implement a `cmp` specialization for ranges
60,337
JuliaLang/julia
35,573
Julia
adienes
LilithHafner
Review this pull request change. Language: Julia File: base/range.jl PR Title: Implement a `cmp` specialization for ranges BEFORE CODE: end _has_length_one(r::OrdinalRange) = first(r) == last(r) _has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r)...
```suggestion (x1, x2) = last(zip(r1, r2)) ``` `min(lastindex(r1), lastindex(r2))` is not offset-safe note that `last(::Zip)` is fast whenever `Iterators.nth` is fast on the range (which it can be by calling `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.
_has_length_one(r::OrdinalRange) = first(r) == last(r) _has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) if lr != length(s) return false elseif iszero(lr) return true end yr, ys = iterate(r), iterate(s) while yr !...
Can this comparison instead not be `cmp(step(r1), step(r2))`? If r1 has a smaller step than r2, then the next elemnent must be smaller. I think this would also work for float ranges.
_has_length_one(r::OrdinalRange) = first(r) == last(r) _has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) if lr != length(s) return false elseif iszero(lr) return true end yr, ys = iterate(r), iterate(s) while yr !...
@@ -1168,6 +1168,17 @@ function ==(r::AbstractRange, s::AbstractRange) return true end +function cmp(r1::AbstractRange{T}, r2::AbstractRange{T}) where {T} + firstindex(r1) == firstindex(r2) || return cmp(firstindex(r1), firstindex(r2)) + (isempty(r1) || isempty(r2)) && return cmp(isempty(r2), isempty(r1))...
base/range.jl
26
Julia
0.571
suggestion
182
51
51
false
Implement a `cmp` specialization for ranges
60,337
JuliaLang/julia
35,573
Julia
jakobnissen
LilithHafner
Review this pull request change. Language: Julia File: base/range.jl PR Title: Implement a `cmp` specialization for ranges BEFORE CODE: _has_length_one(r::OrdinalRange) = first(r) == last(r) _has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) ...
Can this comparison instead not be `cmp(step(r1), step(r2))`? If r1 has a smaller step than r2, then the next elemnent must be smaller. I think this would also work for float ranges.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
const EXAMPLE_RANGES = AbstractRange[ 1:10, 1:5, 1:0, 1:1, 3:2, 3:0, 10:-1:1, 1:2:10, 10:-2:1, LinRange(1.0, 10.0, 10), LinRange(10.0, 1.0, 10), 1e10:1.99:(1e10 + 2), 1e10:(1.99+eps()):(1e10 + 2), StepRangeLen(1, 2, 5), StepRangeLen(10, -2, 5), UInt8(1):UI...
```suggestion @test cmp(a, b) == cmp(collect(a), collect(b)) ``` Isn't exception handling done by `@test` already?
const EXAMPLE_RANGES = AbstractRange[ 1:10, 1:5, 1:0, 1:1, 3:2, 3:0, 10:-1:1, 1:2:10, 10:-2:1, LinRange(1.0, 10.0, 10), LinRange(10.0, 1.0, 10), 1e10:1.99:(1e10 + 2), 1e10:(1.99+eps()):(1e10 + 2), StepRangeLen(1, 2, 5), StepRangeLen(10, -2, 5), UInt8(1):UI...
@@ -2831,3 +2831,30 @@ end @test StepRange(r) == r @test StepRange(r) isa StepRange{Date,Day} end + +const EXAMPLE_RANGES = AbstractRange[ + 1:10, + 1:5, + 1:0, + 1:1, + 3:2, + 3:0, + 10:-1:1, + 1:2:10, + 10:-2:1, + LinRange(1.0, 10.0, 10), + LinRange(10.0, 1.0, 10), + 1e1...
test/ranges.jl
26
Julia
0.857
question
127
27
29
false
Implement a `cmp` specialization for ranges
60,337
JuliaLang/julia
35,573
Julia
Seelengrab
LilithHafner
Review this pull request change. Language: Julia File: test/ranges.jl PR Title: Implement a `cmp` specialization for ranges BEFORE CODE: const EXAMPLE_RANGES = AbstractRange[ 1:10, 1:5, 1:0, 1:1, 3:2, 3:0, 10:-1:1, 1:2:10, 10:-2:1, LinRange(1.0, 10.0, 10), LinRange(10.0, ...
```suggestion @test cmp(a, b) == cmp(collect(a), collect(b)) ``` Isn't exception handling done by `@test` 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.
_has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) if lr != length(s) return false elseif iszero(lr) return true end yr, ys = iterate(r), iterate(s) while yr !== nothing yr[1] == ys[1] || return false ...
`last(zip(r1, r2))` is still the abstract iterator's O(n) isn't it? And if we're doing an O(n) thing, we might as well compare everything, no? The goal here should be to detect the "fast" outs that are _definitively_ correct, falling back to O(n) iteration if we can't do that. The worst case is where `step` is ide...
_has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) if lr != length(s) return false elseif iszero(lr) return true end yr, ys = iterate(r), iterate(s) while yr !== nothing yr[1] == ys[1] || return false ...
@@ -1168,6 +1168,16 @@ function ==(r::AbstractRange, s::AbstractRange) return true end +function cmp(r1::AbstractRange{T}, r2::AbstractRange{T}) where {T} + firstindex(r1) == firstindex(r2) || return cmp(firstindex(r1), firstindex(r2)) + (isempty(r1) || isempty(r2)) && return cmp(isempty(r2), isempty(r1))...
base/range.jl
26
Julia
0.643
performance
427
51
51
false
Implement a `cmp` specialization for ranges
60,337
JuliaLang/julia
35,573
Julia
mbauman
LilithHafner
Review this pull request change. Language: Julia File: base/range.jl PR Title: Implement a `cmp` specialization for ranges BEFORE CODE: _has_length_one(r::AbstractRange) = isone(length(r)) function ==(r::AbstractRange, s::AbstractRange) lr = length(r) if lr != length(s) return false elseif isze...
`last(zip(r1, r2))` is still the abstract iterator's O(n) isn't it? And if we're doing an O(n) thing, we might as well compare everything, no? The goal here should be to detect the "fast" outs that are _definitively_ correct, falling back to O(n) iteration if we can't do that. The worst case is where `step` is ide...
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.
codeinst::CodeInstance codeinfo::CodeInfo sptypes::Vector{VarState} stmtidx::Int desc::String end struct CCallableMissing <: Exception rt sig desc end const ParentMap = IdDict{CodeInstance,Tuple{CodeInstance,Int}} const ErrorList = Vector{Pair{Bool,Any}} # severity => exception const ...
Maybe instead of duplicating, we should move these into the Compiler printing utilities and have `InteractiveUtils` pull them in from there?
codeinst::CodeInstance codeinfo::CodeInfo sptypes::Vector{VarState} stmtidx::Int desc::String end struct CCallableMissing <: Exception rt sig desc end const ParentMap = IdDict{CodeInstance,Tuple{CodeInstance,Int}} const ErrorList = Vector{Pair{Bool,Any}} # severity => exception const ...
@@ -49,76 +49,223 @@ const runtime_functions = Symbol[ ## code for pretty printing ## -# wrap a statement in a typeassert for printing clarity, unless that info seems already obvious -function mapssavaluetypes(codeinfo::CodeInfo, sptypes::Vector{VarState}, stmt) - @nospecialize stmt - newstmt = mapssavalues(...
Compiler/src/verifytrim.jl
26
Julia
0.571
question
140
51
51
false
Make verify trim printing more readable (also fix the colours)
60,350
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/verifytrim.jl PR Title: Make verify trim printing more readable (also fix the colours) BEFORE CODE: codeinst::CodeInstance codeinfo::CodeInfo sptypes::Vector{VarState} stmtidx::Int desc::String end struct CCallableMissing <: Ex...
Maybe instead of duplicating, we should move these into the Compiler printing utilities and have `InteractiveUtils` pull them in from 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.
return isdispatchelem(typ) end # Color printing for types - same colors as code_warntype: # - red bold: unstable/abstract types # - yellow: expected unions (small unions of concrete types) # - light_black: stable concrete types function print_type_colored(io::IO, @nospecialize(typ)) color = get(io, :color, fal...
```suggestion function print_nontype(io::IO, @nospecialize(x), stable::Bool) ``` Not a great name, but better than `print_styled` and `printstyled` floating around in the same function
elseif typ == Core.Box printstyled(io, typ; color=:red, bold=true) elseif typ isa Union && is_expected_union(typ) printstyled(io, typ; color=:yellow) elseif isdispatchelem(typ) printstyled(io, typ; color=:light_black) else printstyled(io, typ; color=:red, bold=true) e...
@@ -49,76 +49,223 @@ const runtime_functions = Symbol[ ## code for pretty printing ## -# wrap a statement in a typeassert for printing clarity, unless that info seems already obvious -function mapssavaluetypes(codeinfo::CodeInfo, sptypes::Vector{VarState}, stmt) - @nospecialize stmt - newstmt = mapssavalues(...
Compiler/src/verifytrim.jl
26
Julia
0.929
suggestion
189
51
51
false
Make verify trim printing more readable (also fix the colours)
60,350
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/verifytrim.jl PR Title: Make verify trim printing more readable (also fix the colours) BEFORE CODE: return isdispatchelem(typ) end # Color printing for types - same colors as code_warntype: # - red bold: unstable/abstract types # - yellow: exp...
```suggestion function print_nontype(io::IO, @nospecialize(x), stable::Bool) ``` Not a great name, but better than `print_styled` and `printstyled` floating around in the same 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.
color = get(io, :color, false)::Bool if !color print(io, typ) elseif typ === Union{} printstyled(io, typ; color=:red) elseif typ == Core.Box printstyled(io, typ; color=:red, bold=true) elseif typ isa Union && is_expected_union(typ) printstyled(io, typ; color=:yellow) ...
This is a really random set of types - Any justification for it? I thought this might be either: - Base types that already print their type (e.g. `Float16`) or are supported as literals - Objects that are self-quoting but it doesn't seem to match either
end end # Print a value with optional stable coloring (light_black if stable) function print_value(io::IO, @nospecialize(x), stable::Bool) stable ? printstyled(io, x; color=:light_black) : print(io, x) end # Unwrap SSAValue and PiNode to get the underlying statement function unwrap_stmt(codeinfo::CodeInfo, @...
@@ -49,76 +49,223 @@ const runtime_functions = Symbol[ ## code for pretty printing ## -# wrap a statement in a typeassert for printing clarity, unless that info seems already obvious -function mapssavaluetypes(codeinfo::CodeInfo, sptypes::Vector{VarState}, stmt) - @nospecialize stmt - newstmt = mapssavalues(...
Compiler/src/verifytrim.jl
26
Julia
0.714
suggestion
265
51
51
false
Make verify trim printing more readable (also fix the colours)
60,350
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/verifytrim.jl PR Title: Make verify trim printing more readable (also fix the colours) BEFORE CODE: color = get(io, :color, false)::Bool if !color print(io, typ) elseif typ === Union{} printstyled(io, typ; color=:red) ...
This is a really random set of types - Any justification for it? I thought this might be either: - Base types that already print their type (e.g. `Float16`) or are supported as literals - Objects that are self-quoting but it doesn't seem to match either
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 !color print(io, typ) elseif typ === Union{} printstyled(io, typ; color=:red) elseif typ == Core.Box printstyled(io, typ; color=:red, bold=true) elseif typ isa Union && is_expected_union(typ) printstyled(io, typ; color=:yellow) elseif isdispatchelem(typ) pr...
The IR verifier seems to suggest that `codeinfo.slotnames` is always populated and the right length - Is that not true?
end # Print a value with optional stable coloring (light_black if stable) function print_value(io::IO, @nospecialize(x), stable::Bool) stable ? printstyled(io, x; color=:light_black) : print(io, x) end # Unwrap SSAValue and PiNode to get the underlying statement function unwrap_stmt(codeinfo::CodeInfo, @nospecia...
@@ -49,76 +49,223 @@ const runtime_functions = Symbol[ ## code for pretty printing ## -# wrap a statement in a typeassert for printing clarity, unless that info seems already obvious -function mapssavaluetypes(codeinfo::CodeInfo, sptypes::Vector{VarState}, stmt) - @nospecialize stmt - newstmt = mapssavalues(...
Compiler/src/verifytrim.jl
26
Julia
0.5
question
119
51
51
false
Make verify trim printing more readable (also fix the colours)
60,350
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/verifytrim.jl PR Title: Make verify trim printing more readable (also fix the colours) BEFORE CODE: if !color print(io, typ) elseif typ === Union{} printstyled(io, typ; color=:red) elseif typ == Core.Box printsty...
The IR verifier seems to suggest that `codeinfo.slotnames` is always populated and the right length - Is that not 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.
stmt.head ∈ (:quote, :inert) && return stmt if stmt.head === :foreigncall return Expr(:call, :ccall, mapssavalues(codeinfo, sptypes, stmt.args[1])) elseif stmt.head ∉ (:new, :method, :toplevel, :thunk) newstmt = Expr(stmt.head) newstmt.args = map!(similar(stmt...
I'm really not a fan of multi-colored parentheses personally They really overload the maximum number of visual items I can track at a time. Do you think they're very helpful?
# Print value with type annotation: value::type function print_typed(io::IO, codeinfo::CodeInfo, sptypes::Vector{VarState}, @nospecialize(stmt), stable::Bool; depth::Int=0, indent::Int=0) typ = widenconst(argextype(stmt, codeinfo, sptypes)) arg_stable = is_type_stable(typ) # Fold deeply...
@@ -49,76 +49,223 @@ const runtime_functions = Symbol[ ## code for pretty printing ## -# wrap a statement in a typeassert for printing clarity, unless that info seems already obvious -function mapssavaluetypes(codeinfo::CodeInfo, sptypes::Vector{VarState}, stmt) - @nospecialize stmt - newstmt = mapssavalues(...
Compiler/src/verifytrim.jl
26
Julia
0.357
question
177
51
51
false
Make verify trim printing more readable (also fix the colours)
60,350
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/verifytrim.jl PR Title: Make verify trim printing more readable (also fix the colours) BEFORE CODE: stmt.head ∈ (:quote, :inert) && return stmt if stmt.head === :foreigncall return Expr(:call, :ccall, mapssavalues(codein...
I'm really not a fan of multi-colored parentheses personally They really overload the maximum number of visual items I can track at a time. Do you think they're very helpful?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end end end return (errors, parents) end # It is unclear if this file belongs in Compiler itself, or should instead be a codegen # driver / verifier implemented by juliac-buildscript.jl for the purpose of extensibility. # For now, it is part of Base.Compiler, but executed with invokelatest ...
```suggestion printstyled(io, "Problem #", no, ": "; color=Base.warn_color(), bold=true) ``` The index is shared but these are counted separately, so changing between "error" / "warning" seems a bit confusing to me
#for i = 1:length(codeinfos) # item = codeinfos[i] # if item isa CodeInstance # println(item, "::", item.rettype) # end #end let severity = 0 if counts[1] > 0 || counts[2] > 0 print(io, "Trim verify finished with ") if counts[1] > 0 ...
@@ -377,9 +524,13 @@ function verify_typeinf_trim(io::IO, codeinfos::Vector{Any}, onlywarn::Bool) warn, desc = desc severity = warn ? 2 : 1 no = (counts[severity] += 1) - print(io, warn ? "Verifier warning #" : "Verifier error #", no, ": ") + if warn + printstyled(io,...
Compiler/src/verifytrim.jl
26
Julia
0.929
suggestion
227
51
33
false
Make verify trim printing more readable (also fix the colours)
60,350
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/verifytrim.jl PR Title: Make verify trim printing more readable (also fix the colours) BEFORE CODE: end end end return (errors, parents) end # It is unclear if this file belongs in Compiler itself, or should instead be ...
```suggestion printstyled(io, "Problem #", no, ": "; color=Base.warn_color(), bold=true) ``` The index is shared but these are counted separately, so changing between "error" / "warning" seems a bit confusing to me
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.
# Color printing for types - same colors as code_warntype: # - red bold: unstable/abstract types # - yellow: expected unions (small unions of concrete types) # - light_black: stable concrete types function print_type_colored(io::IO, @nospecialize(typ)) color = get(io, :color, false)::Bool if !color pri...
Any reason not to always use `repr`?
# Color printing for types - same colors as code_warntype: # - red bold: unstable/abstract types # - yellow: expected unions (small unions of concrete types) # - light_black: stable concrete types function print_type_colored(io::IO, @nospecialize(typ)) color = get(io, :color, false)::Bool if !color pri...
@@ -78,8 +78,10 @@ function print_type_colored(io::IO, @nospecialize(typ)) end # Print with light_black if stable, normal otherwise +# Use repr for strings/chars to show quotes function print_nontype(io::IO, @nospecialize(x), stable::Bool) - stable ? printstyled(io, x; color=:light_black) : print(io, x) + tx...
Compiler/src/verifytrim.jl
26
Julia
0.286
question
36
51
51
false
Make verify trim printing more readable (also fix the colours)
60,350
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: Julia File: Compiler/src/verifytrim.jl PR Title: Make verify trim printing more readable (also fix the colours) BEFORE CODE: # Color printing for types - same colors as code_warntype: # - red bold: unstable/abstract types # - yellow: expected unions (small unions of concr...
Any reason not to always use `repr`?
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.
} JuliaOJIT::JuliaOJIT() : TM(createTargetMachine()), DL(jl_create_datalayout(*TM)), ES(cantFail(orc::SelfExecutorProcessControl::Create(nullptr, std::make_unique<::JuliaTaskDispatcher>()))), GlobalJD(ES.createBareJITDylib("JuliaGlobals")), JD(ES.createBareJITDylib("JuliaOJIT")), ExternalJD(ES.cr...
C++ syntax sometimes is something else
} } llvm::DataLayout jl_create_datalayout(TargetMachine &TM) { // Mark our address spaces as non-integral auto jl_data_layout = TM.createDataLayout(); jl_data_layout = DataLayout(jl_data_layout.getStringRepresentation() + "-ni:10:11:12:13"); return jl_data_layout; } JuliaOJIT::JuliaOJIT() : TM(c...
@@ -1926,7 +1934,8 @@ JuliaOJIT::JuliaOJIT() MemMgr(createRTDyldMemoryManager()), UnlockedObjectLayer( ES, - [this]() { + [this](auto&&...) {
src/jitlayers.cpp
26
C++
0.071
suggestion
38
51
51
false
(Mostly) Trivial part of LLVM 21 support
60,356
JuliaLang/julia
35,573
Julia
gbaraldi
yuyichao
Review this pull request change. Language: C++ File: src/jitlayers.cpp PR Title: (Mostly) Trivial part of LLVM 21 support BEFORE CODE: } JuliaOJIT::JuliaOJIT() : TM(createTargetMachine()), DL(jl_create_datalayout(*TM)), ES(cantFail(orc::SelfExecutorProcessControl::Create(nullptr, std::make_unique<::Julia...
C++ syntax sometimes is something else
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.
pop!(indices) end end end function test_each_in_path(f::Function, basedir) for filepath in find_source_in_path(basedir) @testset "$(relpath(filepath, basedir))" begin e = try JuliaSyntax.parseall(Expr, read(filepath, St...
```suggestion function expr_equal_forgiving(e1, e2; ignore_linenums=true) ``` in keeping with `Base.remove_linenums!`
x->(@assert(!isnothing(x)); @ast _ast_test_graph() @__LINE__() [K"function" x::K"Value"]) ] @testset "every basic case" begin for e in expr_syntax, w1 in expr_wrappers, w2 in expr_wrappers e_wrapped = w2(w1(e)) @test roundtrip(e_wrapped) == e_wrapped end ...
@@ -632,3 +632,93 @@ const JL = JuliaLowering @test JuliaLowering.expr_to_syntaxtree(Expr(:block, Expr(:softscope, true))) ≈ @ast_ [K"block" [K"softscope" true::K"Bool"]] end + +@testset "Expr<->EST" begin + # copied from JuliaSyntax/test/parse_packages.jl + function find_source_in_path(basedir) + ...
JuliaLowering/test/compat.jl
26
Julia
0.786
suggestion
124
51
51
false
`Expr`/`SyntaxTree` parity: trivial conversions
60,373
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/compat.jl PR Title: `Expr`/`SyntaxTree` parity: trivial conversions BEFORE CODE: pop!(indices) end end end function test_each_in_path(f::Function, basedir) for filepath in find_source_in_pa...
```suggestion function expr_equal_forgiving(e1, e2; ignore_linenums=true) ``` in keeping with `Base.remove_linenums!`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
const JS = JuliaSyntax function _insert_tree_node(graph::SyntaxGraph, k::Kind, src::SourceAttrType, attrs=[], flags::UInt16=0x0000) id = newnode!(graph) setattr!(graph, id, :kind, k) flags !== 0 && setattr!(graph, id, :syntax_flags, flags) setattr!(graph, id, :source, src) ...
Maybe a dumb suggestion, but should this do some kind of delta detection to avoid polluting the IR? (i.e. only a emit a `LineNumberNode` when the lineinfo changes from stmt-to-stmt) I'm not sure our debuginfo encoding in Expr is well-defined enough to do that losslessly, but perhaps it's good enough?
k = kind(st) return if k === K"Identifier" n = Symbol(st.name_val) hasattr(st, :scope_layer) ? Expr(:scope_layer, n, st.scope_layer) : n elseif k === K"Value" v = st.value # Let `kind(st) === K"Value"` with `st.value isa Symbol` (or other AST # node). Since we enforc...
@@ -626,3 +626,106 @@ function JuliaSyntax.fixup_Expr_child(::Type{<:SyntaxTree}, head::SyntaxHead, end Base.Expr(ex::SyntaxTree) = JuliaSyntax.to_expr(ex) + +#------------------------------------------------------------------------------- +# WIP: Expr<->EST + +function expr_to_est(@nospecialize(e), lnn::LineNumber...
JuliaLowering/src/compat.jl
26
Julia
0.786
bug
305
732
38
false
`Expr`/`SyntaxTree` parity: trivial conversions
60,373
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/compat.jl PR Title: `Expr`/`SyntaxTree` parity: trivial conversions BEFORE CODE: const JS = JuliaSyntax function _insert_tree_node(graph::SyntaxGraph, k::Kind, src::SourceAttrType, attrs=[], flags::UInt16=0x0000) ...
Maybe a dumb suggestion, but should this do some kind of delta detection to avoid polluting the IR? (i.e. only a emit a `LineNumberNode` when the lineinfo changes from stmt-to-stmt) I'm not sure our debuginfo encoding in Expr is well-defined enough to do that losslessly, but perhaps it's good 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.
SyntaxTree(graph, _expr_to_est(graph, e, lnn)[1]) end function _get_inner_lnn(e::Expr, default::LineNumberNode) e.head in (:function, :macro, :module) || return default length(e.args) >= 2 || return default b = e.args[end] b isa Expr && b.head === :block || return default length(b.args) >= 1 &&...
Does this handle `QuoteNode` of non-self-quoting values correctly? `QuoteNode(LineNumberNode(...))`, `QuoteNode(Expr(...))`, `QuoteNode(Symbol(...))`, etc.
SyntaxTree(graph, _expr_to_est(graph, e, lnn)[1]) end function _get_inner_lnn(e::Expr, default::LineNumberNode) e.head in (:function, :macro, :module) || return default length(e.args) >= 2 || return default b = e.args[end] b isa Expr && b.head === :block || return default length(b.args) >= 1 &&...
@@ -626,3 +626,106 @@ function JuliaSyntax.fixup_Expr_child(::Type{<:SyntaxTree}, head::SyntaxHead, end Base.Expr(ex::SyntaxTree) = JuliaSyntax.to_expr(ex) + +#------------------------------------------------------------------------------- +# WIP: Expr<->EST + +function expr_to_est(@nospecialize(e), lnn::LineNumber...
JuliaLowering/src/compat.jl
26
Julia
0.643
question
158
51
51
false
`Expr`/`SyntaxTree` parity: trivial conversions
60,373
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/compat.jl PR Title: `Expr`/`SyntaxTree` parity: trivial conversions BEFORE CODE: SyntaxTree(graph, _expr_to_est(graph, e, lnn)[1]) end function _get_inner_lnn(e::Expr, default::LineNumberNode) e.head in (:function, :macro, :module) ||...
Does this handle `QuoteNode` of non-self-quoting values correctly? `QuoteNode(LineNumberNode(...))`, `QuoteNode(Expr(...))`, `QuoteNode(Symbol(...))`, etc.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# The following kinds are used in intermediate forms by lowering but are not # part of the surface syntax function _register_kinds() JuliaSyntax.register_kinds!(JuliaLowering, 1, [ # "Syntax extensions" - expression kinds emitted by macros or macro # expansion, and known to lowering. These are part ...
I originally thought that `K"inert_expr"` was so that lowering can know that this needs conversion back to `Expr` when preparing the linearized IR. I was thinking of scenarios like: ```julia macro new_macro() return QuoteNode(quote ... end) # QuoteNode(::SyntaxTree) end macro old_macro() return QuoteNode(...
# The following kinds are used in intermediate forms by lowering but are not # part of the surface syntax function _register_kinds() JuliaSyntax.register_kinds!(JuliaLowering, 1, [ # "Syntax extensions" - expression kinds emitted by macros or macro # expansion, and known to lowering. These are part ...
@@ -21,7 +21,6 @@ function _register_kinds() "Symbol" # QuoteNode; not quasiquote "inert" - "inert_expr"
JuliaLowering/src/kinds.jl
24
Julia
0.929
question
581
49
49
false
`Expr`/`SyntaxTree` parity: trivial conversions
60,373
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/src/kinds.jl PR Title: `Expr`/`SyntaxTree` parity: trivial conversions BEFORE CODE: # The following kinds are used in intermediate forms by lowering but are not # part of the surface syntax function _register_kinds() JuliaSyntax.register_kinds...
I originally thought that `K"inert_expr"` was so that lowering can know that this needs conversion back to `Expr` when preparing the linearized IR. I was thinking of scenarios like: ```julia macro new_macro() return QuoteNode(quote ... end) # QuoteNode(::SyntaxTree) end macro old_macro() return QuoteNode(...
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 JuliaLowering.include_string(test_mod, raw""" @noinline (x = 0xF; x ⊻= 1; x) """; expr_compat_mode=true) == 0xE end @testset "Expr<->EST" begin local roundtrip = e->JuliaLowering.est_to_expr(JuliaLowering.expr_to_est(e)) local roundtrip_eq = x->x==roundtrip(x) local expr_syntax = Any[ ...
Should we file an issue for this?
@test JuliaLowering.include_string(test_mod, raw""" @noinline (x = 0xF; x ⊻= 1; x) """; expr_compat_mode=true) == 0xE end @testset "Expr<->EST" begin local roundtrip = e->JuliaLowering.est_to_expr(JuliaLowering.expr_to_est(e)) local roundtrip_eq = x->x==roundtrip(x) local expr_syntax = Any[ ...
@@ -662,10 +662,12 @@ end x->Expr(:dummy, x) ] + # TODO: `@ast_` escaping is broken
JuliaLowering/test/compat.jl
26
Julia
0.143
question
33
51
51
false
Document and further clean up node creation functions
60,431
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaLowering/test/compat.jl PR Title: Document and further clean up node creation functions BEFORE CODE: @test JuliaLowering.include_string(test_mod, raw""" @noinline (x = 0xF; x ⊻= 1; x) """; expr_compat_mode=true) == 0xE end @testset "Expr<->EST...
Should we file an issue for this?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
const jl_cgval_t &func = argv[1]; const jl_cgval_t &argtypes = argv[2]; if (func.constant && argtypes.constant && jl_is_code_instance(argtypes.constant)) { jl_code_instance_t *codeinst = (jl_code_instance_t*)argtypes.constant; jl_method_instance_t *mi = jl_get_ci_mi(codei...
You probably need to emit_invoke to match this error ``` if (invoke) { return invoke(args[0], &args[2], nargs - 2, codeinst); } else { if (codeinst->owner != jl_nothing || !jl_is_method(codeinst->def->def.value)) { jl_error("Failed to invoke or compile external codeinst"...
const jl_cgval_t &arg = argv[1]; const jl_cgval_t &ty = argv[2]; if (jl_is_type_type(ty.typ) && !jl_has_free_typevars(ty.typ)) { jl_value_t *tp0 = jl_tparam0(ty.typ); emit_typecheck(ctx, arg, tp0, "typeassert"); *ret = update_julia_type(ctx, arg, tp0); ...
@@ -4303,6 +4303,37 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f, return true; } + else if (f == BUILTIN(invoke) && nargs >= 2) { + const jl_cgval_t &func = argv[1]; + const jl_cgval_t &argtypes = argv[2]; + if (func.constant && argtypes.cons...
src/codegen.cpp
26
C++
1
bug
882
51
51
false
Add optimizer support for `invoke(f, ::CodeInstance, args...)`
60,442
JuliaLang/julia
35,573
Julia
vchuravy
MasonProtter
Review this pull request change. Language: C++ File: src/codegen.cpp PR Title: Add optimizer support for `invoke(f, ::CodeInstance, args...)` BEFORE CODE: const jl_cgval_t &func = argv[1]; const jl_cgval_t &argtypes = argv[2]; if (func.constant && argtypes.constant && jl_is_code_instance(arg...
You probably need to emit_invoke to match this error ``` if (invoke) { return invoke(args[0], &args[2], nargs - 2, codeinst); } else { if (codeinst->owner != jl_nothing || !jl_is_method(codeinst->def->def.value)) { jl_error("Failed to invoke or compile external codeinst"...
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.
simpleres = process_simple!(todo, ir, idx, flag, state) simpleres === nothing && continue stmt, sig = simpleres info = inst[:info] # `NativeInterpreter` won't need this, but provide a support for `:invoke` exprs here # for external `AbstractInterpreter`s that may run th...
I think normally we add a `abstract_call_X` handler in abstractinterpretation.jl which returns a `return CallMeta(call.rt, call.exct, call.effects, XCallInfo(..., call.info))` So for you the function to look at ought to be `abstract_invoke`
end elseif contains_is(_PURE_BUILTINS, f) return SomeCase(quoted(val)) elseif contains_is(_EFFECT_FREE_BUILTINS, f) if has_flag(flag, IR_FLAG_NOTHROW) return SomeCase(quoted(val)) end end end if f === compilerbarrier ...
@@ -1577,6 +1649,19 @@ function assemble_inline_todo!(ir::IRCode, state::InliningState) continue end + # Check for invoke with CodeInstance pattern and transform it + # This allows invoke calls with CodeInstance to be resolved at compile time + # Pattern: Expr(:call, invoke,...
Compiler/src/ssair/inlining.jl
26
Julia
0.714
refactor
244
51
51
false
Add optimizer support for `invoke(f, ::CodeInstance, args...)`
60,442
JuliaLang/julia
35,573
Julia
vchuravy
MasonProtter
Review this pull request change. Language: Julia File: Compiler/src/ssair/inlining.jl PR Title: Add optimizer support for `invoke(f, ::CodeInstance, args...)` BEFORE CODE: simpleres = process_simple!(todo, ir, idx, flag, state) simpleres === nothing && continue stmt, sig = simpleres ...
I think normally we add a `abstract_call_X` handler in abstractinterpretation.jl which returns a `return CallMeta(call.rt, call.exct, call.effects, XCallInfo(..., call.info))` So for you the function to look at ought to be `abstract_invoke`
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 if @atomic(ci.invoke) == C_NULL # if invoke is still null after trying to compile the codeinstance, we just fall back # to the interpreter, which will handle errors, or falling back to the methodinstance. return false end if ir.valid_worlds.min_world < @atomic(ci.min_world) |...
Note my comments in https://github.com/JuliaLang/julia/pull/60442#discussion_r2708095815 you should check that you have a `InvokeCICallInfo` and act on that
function narrow_opaque_closure!(ir::IRCode, stmt::Expr, @nospecialize(info::CallInfo), state::InliningState) if isa(info, OpaqueClosureCreateInfo) lbt = argextype(stmt.args[2], ir) lb, exact = instanceof_tfunc(lbt) exact || return ubt = argextype(stmt.args[3], ir) ub, exact =...
@@ -1111,9 +1111,91 @@ function is_builtin(𝕃ₒ::AbstractLattice, s::Signature) return false end +# Check if a call expression is invoke with a CodeInstance as the second argument +# Pattern: Expr(:call, invoke, f, ::CodeInstance, args...) +function is_invoke_with_codeinstance(stmt::Expr, ir::IRCode) + # Must...
Compiler/src/ssair/inlining.jl
26
Julia
0.571
suggestion
156
51
51
false
Add optimizer support for `invoke(f, ::CodeInstance, args...)`
60,442
JuliaLang/julia
35,573
Julia
vchuravy
MasonProtter
Review this pull request change. Language: Julia File: Compiler/src/ssair/inlining.jl PR Title: Add optimizer support for `invoke(f, ::CodeInstance, args...)` BEFORE CODE: end if @atomic(ci.invoke) == C_NULL # if invoke is still null after trying to compile the codeinstance, we just fall back ...
Note my comments in https://github.com/JuliaLang/julia/pull/60442#discussion_r2708095815 you should check that you have a `InvokeCICallInfo` and act 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.
return Future(CallMeta(Bottom, TypeError, EFFECTS_THROWS, NoCallInfo())) elseif !(argtype <: specsig) || ((!isa(method_or_ci.def, ABIOverride) && isa(defdef, Method)) && !(argtype <: defdef.sig)) exct = Union{exct, TypeError} end callee_valid_range = W...
This says that it **must** throw not that it **may** throw. I believe you might just want to go to `return Future(CallMeta(Any, Any, Effects(), NoCallInfo())) `
return Future(CallMeta(Bottom, TypeError, EFFECTS_THROWS, NoCallInfo())) elseif !(argtype <: specsig) || ((!isa(method_or_ci.def, ABIOverride) && isa(defdef, Method)) && !(argtype <: defdef.sig)) exct = Union{exct, TypeError} end callee_valid_range = W...
@@ -2267,6 +2267,15 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt exct = Union{exct, ErrorException} end update_valid_age!(sv, our_world, callee_valid_range) + + if @atomic(method_or_ci.invoke) == C_NULL + @ccall ...
Compiler/src/abstractinterpretation.jl
26
Julia
0.5
suggestion
161
51
51
false
Add optimizer support for `invoke(f, ::CodeInstance, args...)`
60,442
JuliaLang/julia
35,573
Julia
vchuravy
MasonProtter
Review this pull request change. Language: Julia File: Compiler/src/abstractinterpretation.jl PR Title: Add optimizer support for `invoke(f, ::CodeInstance, args...)` BEFORE CODE: return Future(CallMeta(Bottom, TypeError, EFFECTS_THROWS, NoCallInfo())) elseif !(argtype <: specsig) || ((!...
This says that it **must** throw not that it **may** throw. I believe you might just want to go to `return Future(CallMeta(Any, Any, Effects(), NoCallInfo())) `
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.
specsig = get_ci_abi(method_or_ci) defdef = get_ci_mi(method_or_ci).def exct = method_or_ci.exctype if !hasintersect(argtype, specsig) return Future(CallMeta(Bottom, TypeError, EFFECTS_THROWS, NoCallInfo())) elseif !(argtype <: specsig) || ((!i...
This feels sketchy to me. But perhaps @vtjnash has a better idea on if we are allowed to do this?
specsig = get_ci_abi(method_or_ci) defdef = get_ci_mi(method_or_ci).def exct = method_or_ci.exctype if !hasintersect(argtype, specsig) return Future(CallMeta(Bottom, TypeError, EFFECTS_THROWS, NoCallInfo())) elseif !(argtype <: specsig) || ((!i...
@@ -2267,6 +2267,15 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt exct = Union{exct, ErrorException} end update_valid_age!(sv, our_world, callee_valid_range) + + if @atomic(method_or_ci.invoke) == C_NULL + @ccall ...
Compiler/src/abstractinterpretation.jl
26
Julia
0.286
question
97
51
51
false
Add optimizer support for `invoke(f, ::CodeInstance, args...)`
60,442
JuliaLang/julia
35,573
Julia
vchuravy
MasonProtter
Review this pull request change. Language: Julia File: Compiler/src/abstractinterpretation.jl PR Title: Add optimizer support for `invoke(f, ::CodeInstance, args...)` BEFORE CODE: specsig = get_ci_abi(method_or_ci) defdef = get_ci_mi(method_or_ci).def exct = method_or_ci.exctype ...
This feels sketchy to me. But perhaps @vtjnash has a better idea on if we are allowed to do this?
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 isa(third_arg_type, Const) && isa(third_arg_type.val, CodeInstance) return true end return false end # Transform invoke call with CodeInstance to :invoke expression # Transforms: Expr(:call, invoke, f, ::CodeInstance, args...) # Into: Expr(:invoke, ::CodeInstance, f, args...) function transform_...
This can potentially cause stack overflow or deadlock and is not safe here. Observing the value of invoke (other than for const flag) is invalid in inference therefore
if isa(result, ConcreteResult) item = concrete_result_item(result, info, state) elseif isa(result, SemiConcreteResult) item = semiconcrete_result_item(result, info, flag, state) else argtypes = invoke_rewrite(sig.argtypes) if isa(result, InferenceResult) mi = resu...
@@ -1111,9 +1111,91 @@ function is_builtin(𝕃ₒ::AbstractLattice, s::Signature) return false end +# Check if a call expression is invoke with a CodeInstance as the second argument +# Pattern: Expr(:call, invoke, f, ::CodeInstance, args...) +function is_invoke_with_codeinstance(stmt::Expr, ir::IRCode) + # Must...
Compiler/src/ssair/inlining.jl
26
Julia
0.571
bug
168
51
51
false
Add optimizer support for `invoke(f, ::CodeInstance, args...)`
60,442
JuliaLang/julia
35,573
Julia
vtjnash
MasonProtter
Review this pull request change. Language: Julia File: Compiler/src/ssair/inlining.jl PR Title: Add optimizer support for `invoke(f, ::CodeInstance, args...)` BEFORE CODE: if isa(third_arg_type, Const) && isa(third_arg_type.val, CodeInstance) return true end return false end # Transform invoke ...
This can potentially cause stack overflow or deadlock and is not safe here. Observing the value of invoke (other than for const flag) is invalid in inference therefore
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.
# Transforms: Expr(:call, invoke, f, ::CodeInstance, args...) # Into: Expr(:invoke, ::CodeInstance, f, args...) function transform_invoke_codeinstance!(ir::IRCode, idx::Int, stmt::Expr) # Extract the CodeInstance from stmt.args[3] ci_arg = stmt.args[3] # Resolve to actual CodeInstance if needed ci::Cod...
World range comparisons seem incorrect here. The seq-cst atomic here which fails to sequence anything should have been a hint that this is dangerously unsynchronized and needs to be done more carefully elsewhere
mi = result.linfo validate_sparams(mi.sparam_vals) || return nothing if Union{} !== argtypes_to_type(argtypes) <: mi.def.sig item = resolve_todo(mi, result, info, flag, state) handle_single_case!(todo, ir, idx, stmt, item, true) return ...
@@ -1111,9 +1111,91 @@ function is_builtin(𝕃ₒ::AbstractLattice, s::Signature) return false end +# Check if a call expression is invoke with a CodeInstance as the second argument +# Pattern: Expr(:call, invoke, f, ::CodeInstance, args...) +function is_invoke_with_codeinstance(stmt::Expr, ir::IRCode) + # Must...
Compiler/src/ssair/inlining.jl
26
Julia
0.5
bug
211
51
51
false
Add optimizer support for `invoke(f, ::CodeInstance, args...)`
60,442
JuliaLang/julia
35,573
Julia
vtjnash
MasonProtter
Review this pull request change. Language: Julia File: Compiler/src/ssair/inlining.jl PR Title: Add optimizer support for `invoke(f, ::CodeInstance, args...)` BEFORE CODE: # Transforms: Expr(:call, invoke, f, ::CodeInstance, args...) # Into: Expr(:invoke, ::CodeInstance, f, args...) function transform_invoke_codein...
World range comparisons seem incorrect here. The seq-cst atomic here which fails to sequence anything should have been a hint that this is dangerously unsynchronized and needs to be done more carefully 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.
length(d) == 1 ? "$(d[1])-element" : join(map(string,d), '×') inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summa...
There's no need to add a docstring for methods that are already documented by the generic function docstring and don't deviate from the generic interface. ```suggestion ```
length(d) == 1 ? "$(d[1])-element" : join(map(string,d), '×') inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summa...
@@ -3128,6 +3128,24 @@ function array_summary(io::IO, a, inds) print(io, " with indices ", inds2string(inds)) end +""" + summary(io::IO, ref::GenericMemoryRef) + +Print a brief description of a `GenericMemoryRef`, showing the remaining +accessible length from the current offset. This improves error messages ...
base/show.jl
26
Julia
0.714
suggestion
176
51
51
false
Add summary printing for GenericMemoryRef
60,451
JuliaLang/julia
35,573
Julia
LilithHafner
vishal2005025
Review this pull request change. Language: Julia File: base/show.jl PR Title: Add summary printing for GenericMemoryRef BEFORE CODE: length(d) == 1 ? "$(d[1])-element" : join(map(string,d), '×') inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indss...
There's no need to add a docstring for methods that are already documented by the generic function docstring and don't deviate from the generic interface. ```suggestion ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
_indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}}) print(io, dims2string(l...
I prefer the variable naming in https://github.com/JuliaLang/julia/pull/57278/files
_indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}}) print(io, dims2string(l...
@@ -3128,6 +3128,24 @@ function array_summary(io::IO, a, inds) print(io, " with indices ", inds2string(inds)) end +""" + summary(io::IO, ref::GenericMemoryRef) + +Print a brief description of a `GenericMemoryRef`, showing the remaining +accessible length from the current offset. This improves error messages ...
base/show.jl
26
Julia
0.286
suggestion
83
51
51
false
Add summary printing for GenericMemoryRef
60,451
JuliaLang/julia
35,573
Julia
LilithHafner
vishal2005025
Review this pull request change. Language: Julia File: base/show.jl PR Title: Add summary printing for GenericMemoryRef BEFORE CODE: _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a:...
I prefer the variable naming in https://github.com/JuliaLang/julia/pull/57278/files
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.
join(map(string,d), '×') inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) = array_summary(io, a, ax...
No need to specify type parameters
join(map(string,d), '×') inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.indices) # anything array-like gets summarized e.g. 10-element Array{Int64,1} summary(io::IO, a::AbstractArray) = array_summary(io, a, ax...
@@ -3128,6 +3128,24 @@ function array_summary(io::IO, a, inds) print(io, " with indices ", inds2string(inds)) end +""" + summary(io::IO, ref::GenericMemoryRef) + +Print a brief description of a `GenericMemoryRef`, showing the remaining +accessible length from the current offset. This improves error messages ...
base/show.jl
26
Julia
0.214
suggestion
34
51
51
false
Add summary printing for GenericMemoryRef
60,451
JuliaLang/julia
35,573
Julia
LilithHafner
vishal2005025
Review this pull request change. Language: Julia File: base/show.jl PR Title: Add summary printing for GenericMemoryRef BEFORE CODE: join(map(string,d), '×') inds2string(inds) = join(map(_indsstring,inds), '×') _indsstring(i) = string(i) _indsstring(i::Union{IdentityUnitRange, Slice}) = string(i.i...
No need to specify type parameters
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.
summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}}) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) ...
Is this empty case ever hit? If so, demonstrate that with a test. Otherwise, remove it.
summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}}) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) end function array_summary(io::IO, a, inds) print(io, dims2string(length.(inds)), " ") showarg(io, a, true) ...
@@ -3128,6 +3128,24 @@ function array_summary(io::IO, a, inds) print(io, " with indices ", inds2string(inds)) end +""" + summary(io::IO, ref::GenericMemoryRef) + +Print a brief description of a `GenericMemoryRef`, showing the remaining +accessible length from the current offset. This improves error messages ...
base/show.jl
26
Julia
0.286
question
87
51
51
false
Add summary printing for GenericMemoryRef
60,451
JuliaLang/julia
35,573
Julia
LilithHafner
vishal2005025
Review this pull request change. Language: Julia File: base/show.jl PR Title: Add summary printing for GenericMemoryRef BEFORE CODE: summary(io::IO, a::AbstractArray) = array_summary(io, a, axes(a)) function array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}}) print(io, dims2string(length.(inds)), " ") show...
Is this empty case ever hit? If so, demonstrate that with a test. Otherwise, remove 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.
push!(a, x) end return a end # make a collection similar to `c` and appropriate for collecting `itr` _similar_for(c, ::Type{T}, itr, isz, shp) where {T} = similar(c, T) _similar_shape(itr, ::SizeUnknown) = nothing _similar_shape(itr, ::HasLength) = length(itr)::Integer _similar_shape(itr, ::HasShape) ...
This is the main point of contention: JET can not rule out that this method ends up calling itself recursively, which then leads to follow-up weirdness (like it looking for a `length(::HasLength)` method, and of course failing to find one). I am open for better names than `_array_for2` (perhaps `_array_for_inner` ?)...
push!(a, x) end return a end # make a collection similar to `c` and appropriate for collecting `itr` _similar_for(c, ::Type{T}, itr, isz, shp) where {T} = similar(c, T) _similar_shape(itr, ::SizeUnknown) = nothing _similar_shape(itr, ::HasLength) = length(itr)::Integer _similar_shape(itr, ::HasShape) ...
@@ -696,12 +696,12 @@ _similar_for(c::AbstractArray, ::Type{T}, itr, ::HasShape, axs) where {T} = similar(c, T, axs) # make a collection appropriate for collecting `itr::Generator` -_array_for(::Type{T}, ::SizeUnknown, ::Nothing) where {T} = Vector{T}(undef, 0) -_array_for(::Type{T}, ::HasLength, len::Integer) ...
base/array.jl
26
Julia
0.643
bug
321
51
51
false
Fix JET warning related to `_array_for`
60,461
JuliaLang/julia
35,573
Julia
fingolfin
fingolfin
Review this pull request change. Language: Julia File: base/array.jl PR Title: Fix JET warning related to `_array_for` BEFORE CODE: push!(a, x) end return a end # make a collection similar to `c` and appropriate for collecting `itr` _similar_for(c, ::Type{T}, itr, isz, shp) where {T} = similar(c, T...
This is the main point of contention: JET can not rule out that this method ends up calling itself recursively, which then leads to follow-up weirdness (like it looking for a `length(::HasLength)` method, and of course failing to find one). I am open for better names than `_array_for2` (perhaps `_array_for_inner` ?)...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
([K"=" [K"call" _...] _...], when=(args=if_valid_get_args(st[1]); !isnothing(args))) -> "deprecated call-equals form with args $args" (_, run=show("printf debugging is great")) -> "something else" _ -> "something else" end "normal function foo" ``` See [Racket `match`](https://docs.racket-lang.org/...
Do either of these TODO's need to happen before merging?
[K"function" fname] -> "zero-method function $fname" [K"function" [K"call" fname args...] body] -> "normal function $fname" ([K"=" [K"call" _...] _...], when=(args=if_valid_get_args(st[1]); !isnothing(args))) -> "deprecated call-equals form with args $args" (_, when=(show("printf...
@@ -735,6 +735,241 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.214
question
56
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: ([K"=" [K"call" _...] _...], when=(args=if_valid_get_args(st[1]); !isnothing(args))) -> "deprecated call-equals form with args $args" (_, run=sh...
Do either of these TODO's need to happen before merging?
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.
## Patterns A pattern is used as both a conditional (does this syntax tree have a certain structure?) and a `let` (bind trees to these names if so). Each pattern uses a limited version of the @ast syntax: ``` <pattern> = <tree_identifier> | [K"<kind>" <pattern>*] | [K"<kind>" <pattern>* <list_ide...
Do you have motivating examples for multiple `when` clauses, or for `run=...`? I looked in https://github.com/JuliaLang/JuliaLowering.jl/pull/93/ but didn't find any, and my "KISS" demon says that multiple `when=...` can be done with just `&&` and `run` and is just `when=(code; true)`
## Patterns A pattern is used as both a conditional (does this syntax tree have a certain structure?) and a `let` (bind trees to these names if so). Each pattern uses a limited version of the @ast syntax: ``` <pattern> = <tree_identifier> | [K"<kind>" <pattern>*] | [K"<kind>" <pattern>* <list_ide...
@@ -740,6 +740,263 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.643
suggestion
288
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: ## Patterns A pattern is used as both a conditional (does this syntax tree have a certain structure?) and a `let` (bind trees to these names if so). Each patt...
Do you have motivating examples for multiple `when` clauses, or for `run=...`? I looked in https://github.com/JuliaLang/JuliaLowering.jl/pull/93/ but didn't find any, and my "KISS" demon says that multiple `when=...` can be done with just `&&` and `run` and is just `when=(code; 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.
pattern. They are executed in order, stopping if any `when=cond` evaluates to false. These may not mutate the object being matched. ## Scope of variables Every `(pattern, extras...) -> result` introduces a local scope. Identifiers in the pattern are let-bound when evaluating `extras` and `result`. Any `extra` can ...
Is the last branch here intended to be unreachable?
## Scope of variables Every `(pattern, when=cond) -> result` introduces a local scope. Identifiers in the pattern are let-bound when evaluating `cond` and `result`. `cond` can introduce variables for use in `result`. User code in `cond` and `result` (but not `pattern`) can refer to outer variables. ## Example ```...
@@ -740,6 +740,263 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.214
question
51
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: pattern. They are executed in order, stopping if any `when=cond` evaluates to false. These may not mutate the object being matched. ## Scope of variables Ev...
Is the last branch here intended to be unreachable?
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.
push!(needs_else, case) needs_else = needs_else[3].args end push!(needs_else, :(throw(ErrorException(string( "No match found for `", $st_gs, "` at ", $(string(line))))))) return esc(out_blk) end function _stm_vcat_to_hcat(p::Expr) Meta.isexpr(p, :vcat) || return ...
Hmm, having to copy / filter / scan the input `Expr` every time we pattern-match seems like it'd be slow compared to what I'd expect this macro to expand to (a few `if-else` checks) Is it possible to make this more like `_stm_assigns` and compute the effective checking logic as an expression?
push!(case_list_tail, :(throw(ErrorException(string( "No match found for `", $st_gs, "` at ", $(string(line))))))) return esc(out_blk) end # recursively flatten `vcat` expressions function _stm_vcat_to_hcat(p::Expr) if Meta.isexpr(p, :vcat) out = Expr(:hcat) for a in...
@@ -740,6 +740,263 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.571
performance
296
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: push!(needs_else, case) needs_else = needs_else[3].args end push!(needs_else, :(throw(ErrorException(string( "No...
Hmm, having to copy / filter / scan the input `Expr` every time we pattern-match seems like it'd be slow compared to what I'd expect this macro to expand to (a few `if-else` checks) Is it possible to make this more like `_stm_assigns` and compute the effective checking logic as an expression?
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.
raw""" Simple `SyntaxTree` pattern matching Returns the first result where its corresponding pattern matches `syntax_tree` and each extra `cond` is true. Throws an error if no match is found. ## Patterns A pattern is used as both a conditional (does this syntax tree have a certain structure?) and a `let` (bind tree...
```suggestion ## Extra conditions: `when` ```
raw""" Simple `SyntaxTree` pattern matching Returns the first result where its corresponding pattern matches `syntax_tree` and each extra `cond` is true. Throws an error if no match is found. ## Patterns A pattern is used as both a conditional (does this syntax tree have a certain structure?) and a `let` (bind tree...
@@ -740,6 +740,268 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.429
suggestion
47
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: raw""" Simple `SyntaxTree` pattern matching Returns the first result where its corresponding pattern matches `syntax_tree` and each extra `cond` is true. Thro...
```suggestion ## Extra conditions: `when` ```
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.
id2 = new_id!(graph2) seen[id1] = id2 src1 = get(SyntaxTree(graph1, id1), :source, nothing) src2 = if !copy_source src1 elseif src1 isa NodeId _copy_ast(graph2, graph1, src1, seen, copy_source) elseif src1 isa Tuple map(i->_copy_ast(graph2, graph1, i, seen, copy_source), ...
```suggestion # AST destructuring utilities ```
id2 = new_id!(graph2) seen[id1] = id2 src1 = get(SyntaxTree(graph1, id1), :source, nothing) src2 = if !copy_source src1 elseif src1 isa NodeId _copy_ast(graph2, graph1, src1, seen, copy_source) elseif src1 isa Tuple map(i->_copy_ast(graph2, graph1, i, seen, copy_source), ...
@@ -740,6 +740,268 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.429
suggestion
49
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: id2 = new_id!(graph2) seen[id1] = id2 src1 = get(SyntaxTree(graph1, id1), :source, nothing) src2 = if !copy_source src1 elseif src1 ...
```suggestion # AST destructuring utilities ```
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.
<pattern> = <tree_identifier> | [K"<kind>" <pattern>*] | [K"<kind>" <pattern>* <list_identifier>... <pattern>*] # note "*" is the meta-operator meaning one or more, and "..." is literal ``` where a `[K"k" p1 p2 ps...]` form matches any tree with kind `k` and >=2 children (bound to `p1` and `p2`), ...
Very nice, this seems exactly what we want.
<pattern> = <tree_identifier> | [K"<kind>" <pattern>*] | [K"<kind>" <pattern>* <list_identifier>... <pattern>*] # note "*" is the meta-operator meaning one or more, and "..." is literal ``` where a `[K"k" p1 p2 ps...]` form matches any tree with kind `k` and >=2 children (bound to `p1` and `p2`), ...
@@ -740,6 +740,268 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.071
suggestion
43
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: <pattern> = <tree_identifier> | [K"<kind>" <pattern>*] | [K"<kind>" <pattern>* <list_identifier>... <pattern>*] # note "*" is the meta-oper...
Very nice, this seems exactly what we want.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@assert(length(p.args) === 1, "use spaces, not commas, in @stm []-patterns") elseif Meta.isexpr(p, :hcat) @assert(length(p.args) >= 2) elseif Meta.isexpr(p, :vcat) p = _stm_vcat_to_hcat(p) @assert(length(p.args) >= 2) else ...
```suggestion @assert Meta.isexpr(pats, :block) "Usage: @stm st begin; ...; end" ```
@assert(length(p.args) === 1, "use spaces, not commas, in @stm []-patterns") elseif Meta.isexpr(p, :hcat) @assert(length(p.args) >= 2) elseif Meta.isexpr(p, :vcat) p = _stm_vcat_to_hcat(p) @assert(length(p.args) >= 2) else ...
@@ -740,6 +740,268 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.571
suggestion
90
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: @assert(length(p.args) === 1, "use spaces, not commas, in @stm []-patterns") elseif Meta.isexpr(p, :hcat) @a...
```suggestion @assert Meta.isexpr(pats, :block) "Usage: @stm st begin; ...; end" ```
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.
See [Racket `match`](https://docs.racket-lang.org/reference/match.html) for the inspiration for this macro and an example of a much more featureful pattern language. """ macro stm(st, pats) _stm(__source__, st, pats; debug=false) end "Like `@stm`, but prints a trace during matching." macro stm_debug(st, pats) ...
`needs_else`? I can see what this does (clever trick with the `if false` btw) but this variable name seemed quite confusing reading the code
See [Racket `match`](https://docs.racket-lang.org/reference/match.html) for the inspiration for this macro and an example of a much more featureful pattern language. """ macro stm(st, pats) _stm(__source__, st, pats; debug=false) end "Like `@stm`, but prints a trace during matching." macro stm_debug(st, pats) ...
@@ -740,6 +740,268 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +#------------------------------------------------------------------------------- +# AST destruction utilities + +raw""" +Simple `SyntaxTree` pattern matching + +Returns the first result where its corresponding pat...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.5
suggestion
140
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: See [Racket `match`](https://docs.racket-lang.org/reference/match.html) for the inspiration for this macro and an example of a much more featureful pattern lang...
`needs_else`? I can see what this does (clever trick with the `if false` btw) but this variable name seemed quite confusing reading the code
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 @testset "nested patterns" begin @test 1 === @stm st begin [K"call" _::K"Identifier" _::K"Identifier" [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" _::K"Identifier" k2]]] -> 1 [K"call" _::K"Identifier" _::K"Identifier" [K"kw" _::K"Identifier" k1] [...
Oh, this wasn't what I had in mind. My thought was to copy the same meaning that `@ast` uses so that we have ```suggestion [K"call" x::K"Identifier" _ _ _] -> x == "foo" ``` I don't think the `x::K"blah"` syntax is fitting if we want to get the actual node. (I do think it would be useful to have ...
[K"call" _ _ [K"None" [K"Identifier"] k1] [K"None" [K"Identifier"] [K"None" [K"None"] k2]]] -> 5 [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"None" [K"Identifier"] [K"None" [K"None"] k2]]] -> 4 [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"None" [K"None"] k2]]] ->...
@@ -100,3 +100,233 @@ end @test_throws ErrorException copy_ast(new_g, st; copy_source=false) end end + +@testset "@stm SyntaxTree pattern-matching" begin + st = parsestmt(SyntaxTree, "foo(a,b=1,c(d=2))") + # (call foo a (kw b 1) (call c (kw d 2))) + + @testset "basic functionality" begin + ...
JuliaSyntax/test/syntax_graph.jl
26
Julia
0.857
suggestion
439
51
51
false
Add `@stm` "SyntaxTree match" macro
60,475
JuliaLang/julia
35,573
Julia
c42f
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/test/syntax_graph.jl PR Title: Add `@stm` "SyntaxTree match" macro BEFORE CODE: end end @testset "nested patterns" begin @test 1 === @stm st begin [K"call" _::K"Identifier" _::K"Identifier" [K"kw" _::K"Identifier...
Oh, this wasn't what I had in mind. My thought was to copy the same meaning that `@ast` uses so that we have ```suggestion [K"call" x::K"Identifier" _ _ _] -> x == "foo" ``` I don't think the `x::K"blah"` syntax is fitting if we want to get the actual node. (I do think it would be useful to have ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# # (The flisp parser only considers commas before `;` and thus gets this # last case wrong) op_pos = bump_dotted(ps, op_dotted, emit_dot_node=true, remap_kind=K"Identifier") space_before_paren = preceding_whitespace(t2) if space_before_paren # Setup possible...
Possibly neater? ```suggestion end opts::NamedTuple{(:needs_parameters, :is_paren_call, :is_block, :delim_flags), Tuple{Bool, Bool, Bool, RawFlags}} ```
# # (The flisp parser only considers commas before `;` and thus gets this # last case wrong) op_pos = bump_dotted(ps, op_dotted, emit_dot_node=true, remap_kind=K"Identifier") space_before_paren = preceding_whitespace(t2) if space_before_paren # Setup possible...
@@ -1280,7 +1280,7 @@ function parse_unary(ps::ParseState) return (needs_parameters=is_paren_call, is_paren_call=is_paren_call, is_block=!is_paren_call && num_semis > 0) - end + end::NamedTuple{(:needs_parameters, :is_paren_call, :is_block, :delim_fla...
JuliaSyntax/src/julia/parser.jl
26
Julia
0.714
suggestion
174
51
51
false
[JuliaSyntax] Add type-asserts to the results of `parse_brackets()`
60,476
JuliaLang/julia
35,573
Julia
c42f
JamesWrigley
Review this pull request change. Language: Julia File: JuliaSyntax/src/julia/parser.jl PR Title: [JuliaSyntax] Add type-asserts to the results of `parse_brackets()` BEFORE CODE: # # (The flisp parser only considers commas before `;` and thus gets this # last case wrong) op_pos = bump...
Possibly neater? ```suggestion end opts::NamedTuple{(:needs_parameters, :is_paren_call, :is_block, :delim_flags), Tuple{Bool, Bool, Bool, RawFlags}} ```
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.
detect_closure_boxes(mod1, mod2...; recursive=false) Return a vector of `(Method, varname)` pairs for methods defined in the specified modules that allocate `Core.Box` in their lowered code. If `recursive=false`, each module is treated as a root module (for example, `Base` matches `Base.Compiler`), but submodules ...
``` julia> Test.detect_unbound_args() ERROR: TypeError: in typeassert, expected Vector{Module}, got a value of type Vector{Union{}} ```
detect_closure_boxes(mod1, mod2...) Return a sorted `Vector{Pair{Method, Vector{Symbol}}}` of methods defined in the specified modules (or their submodules) that allocate `Core.Box` in their lowered code, paired with the boxed variable names. Variable names are `:unknown` when a slot name cannot be resolved. See ...
@@ -2583,7 +2667,7 @@ function detect_unbound_args(mods...; allowed_undefineds=nothing) @nospecialize mods ambs = Set{Method}() - mods = collect(mods)::Vector{Module}
stdlib/Test/src/Test.jl
26
Julia
0.857
suggestion
138
51
51
false
add a vibe coded `Test.detect_closure_boxes` for closure boxes in loaded code
60,478
JuliaLang/julia
35,573
Julia
KristofferC
KristofferC
Review this pull request change. Language: Julia File: stdlib/Test/src/Test.jl PR Title: add a vibe coded `Test.detect_closure_boxes` for closure boxes in loaded code BEFORE CODE: detect_closure_boxes(mod1, mod2...; recursive=false) Return a vector of `(Method, varname)` pairs for methods defined in the specif...
``` julia> Test.detect_unbound_args() ERROR: TypeError: in typeassert, expected Vector{Module}, got a value of type Vector{Union{}} ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end end end end end examine(Core.methodtable) return collect(ambs) end """ detect_closure_boxes(mod1, mod2...; recursive=false) Return a vector of `(Method, varname)` pairs for methods defined in the specified modules that allocate `Core.Box` in ...
```suggestion function is_box_call(@nospecialize expr) ```
end end end end end examine(Core.methodtable) return collect(ambs) end """ detect_closure_boxes(mod1, mod2...) Return a sorted `Vector{Pair{Method, Vector{Symbol}}}` of methods defined in the specified modules (or their submodules) that allocate ...
@@ -2557,6 +2557,90 @@ function detect_ambiguities(mods::Module...; return collect(ambs) end +""" + detect_closure_boxes(mod1, mod2...; recursive=false) + +Return a vector of `(Method, varname)` pairs for methods defined in the specified +modules that allocate `Core.Box` in their lowered code. If `recursive=...
stdlib/Test/src/Test.jl
26
Julia
0.571
suggestion
64
51
51
false
add a vibe coded `Test.detect_closure_boxes` for closure boxes in loaded code
60,478
JuliaLang/julia
35,573
Julia
aviatesk
KristofferC
Review this pull request change. Language: Julia File: stdlib/Test/src/Test.jl PR Title: add a vibe coded `Test.detect_closure_boxes` for closure boxes in loaded code BEFORE CODE: end end end end end examine(Core.methodtable) return collect(ambs) e...
```suggestion function is_box_call(@nospecialize expr) ```
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.
""" detect_ambiguities(mod1, mod2...; recursive=false, ambiguous_bottom=false, allowed_undefineds=nothing) Return a vector of `(Method,Method)` pairs of ambiguous methods defined in the specified modules. Use `recursive=true` to test in al...
Unrelated bugfix, should be separated out into independent PR and backported to v1.10, v1.12, v1.13?
""" detect_ambiguities(mod1, mod2...; recursive=false, ambiguous_bottom=false, allowed_undefineds=nothing) Return a vector of `(Method,Method)` pairs of ambiguous methods defined in the specified modules. Use `recursive=true` to test in al...
@@ -2527,7 +2527,7 @@ function detect_ambiguities(mods::Module...; allowed_undefineds = nothing) @nospecialize ambs = Set{Tuple{Method,Method}}() - mods = collect(mods)::Vector{Module} + mods = Module[mods...]
stdlib/Test/src/Test.jl
26
Julia
0.571
bug
100
51
51
false
add a vibe coded `Test.detect_closure_boxes` for closure boxes in loaded code
60,478
JuliaLang/julia
35,573
Julia
nsajko
KristofferC
Review this pull request change. Language: Julia File: stdlib/Test/src/Test.jl PR Title: add a vibe coded `Test.detect_closure_boxes` for closure boxes in loaded code BEFORE CODE: """ detect_ambiguities(mod1, mod2...; recursive=false, ambiguous_bottom=false, ...
Unrelated bugfix, should be separated out into independent PR and backported to v1.10, v1.12, v1.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.
""" mutable struct CPUinfo model::String speed::Int32 cpu_times!user::UInt64 cpu_times!nice::UInt64 cpu_times!sys::UInt64 cpu_times!idle::UInt64 cpu_times!irq::UInt64 CPUinfo(model,speed,u,n,s,id,ir)=new(model,speed,u,n,s,id,ir) end CPUinfo(info::UV_cpu_info_t) = CPUinfo(unsafe_string(in...
```suggestion unit = " s " ms_per_s = 1000 ```
""" mutable struct CPUinfo model::String speed::Int32 cpu_times!user::UInt64 cpu_times!nice::UInt64 cpu_times!sys::UInt64 cpu_times!idle::UInt64 cpu_times!irq::UInt64 CPUinfo(model,speed,u,n,s,id,ir)=new(model,speed,u,n,s,id,ir) end CPUinfo(info::UV_cpu_info_t) = CPUinfo(unsafe_string(in...
@@ -246,24 +243,19 @@ CPUinfo(info::UV_cpu_info_t) = CPUinfo(unsafe_string(info.model), info.speed, public CPUinfo function _show_cpuinfo(io::IO, info::Sys.CPUinfo, header::Bool=true, prefix::AbstractString=" ") - tck = SC_CLK_TCK if header println(io, info.model, ": ") print(io, " "^le...
base/sysinfo.jl
26
Julia
0.571
suggestion
58
51
51
false
Clarify that `cpu_info` times are expressed in milliseconds
60,480
JuliaLang/julia
35,573
Julia
topolarity
BioTurboNick
Review this pull request change. Language: Julia File: base/sysinfo.jl PR Title: Clarify that `cpu_info` times are expressed in milliseconds BEFORE CODE: """ mutable struct CPUinfo model::String speed::Int32 cpu_times!user::UInt64 cpu_times!nice::UInt64 cpu_times!sys::UInt64 cpu_times!idle::...
```suggestion unit = " s " ms_per_s = 1000 ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end end end @testset "username()" begin if Sys.isunix() passwd = Libc.getpwuid(Libc.getuid()) @test Sys.username() == passwd.username elseif Sys.iswindows() @test Sys.username() == ENV["USERNAME"] else @test !isempty(Sys.username()) end end @testset "Base.Sy...
```suggestion ``` Probably get rid of these `SC_CLK_TCK` overrides, now that they are unnecessary
end end end @testset "username()" begin if Sys.isunix() passwd = Libc.getpwuid(Libc.getuid()) @test Sys.username() == passwd.username elseif Sys.iswindows() @test Sys.username() == ENV["USERNAME"] else @test !isempty(Sys.username()) end end @testset "Base.Sy...
@@ -72,7 +72,7 @@ end Sys.SC_CLK_TCK, save_SC_CLK_TCK = 100, Sys.SC_CLK_TCK # use platform-independent tick units
test/sysinfo.jl
26
Julia
0.571
suggestion
99
32
30
false
Clarify that `cpu_info` times are expressed in milliseconds
60,480
JuliaLang/julia
35,573
Julia
topolarity
BioTurboNick
Review this pull request change. Language: Julia File: test/sysinfo.jl PR Title: Clarify that `cpu_info` times are expressed in milliseconds BEFORE CODE: end end end @testset "username()" begin if Sys.isunix() passwd = Libc.getpwuid(Libc.getuid()) @test Sys.username() == passwd.user...
```suggestion ``` Probably get rid of these `SC_CLK_TCK` overrides, now that they are unnecessary
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> Base.rstrip_shell("echo 'Hello World' \\ ") "echo 'Hello World' \\ " julia> Base.rstrip_shell("echo 'Hello World' ") "echo 'Hello World'" ``` """ function rstrip_shell(s::AbstractString) c_old = nothing for (i, c) in Iterators.reverse(pairs(s)) i::Int; c::AbstractChar ((...
```suggestion # N.B.: Any functions starting with __repl_entry cut off backtraces when printing in the REPL. function __repl_entry_shell_parse(str::AbstractString, interpolate::Bool, special::AbstractString, filename) ``` Elsewhere we have this comment, which is very helpful as function names are typically not sema...
```jldoctest julia> Base.rstrip_shell("echo 'Hello World' \\ ") "echo 'Hello World' \\ " julia> Base.rstrip_shell("echo 'Hello World' ") "echo 'Hello World'" ``` """ function rstrip_shell(s::AbstractString) c_old = nothing for (i, c) in Iterators.reverse(pairs(s)) i::Int; c::AbstractChar ((...
@@ -28,8 +28,11 @@ function rstrip_shell(s::AbstractString) SubString(s, 1, 0) end) -function shell_parse(str::AbstractString, interpolate::Bool=true; - special::AbstractString="", filename="none") +shell_parse(str::AbstractString, interpolate::Bool=true; + special::AbstractString...
base/shell.jl
26
Julia
0.786
refactor
340
51
51
false
Use `__repl_entry` prefix to shorten `shell_parse` stack traces
60,482
JuliaLang/julia
35,573
Julia
LilithHafner
BioTurboNick
Review this pull request change. Language: Julia File: base/shell.jl PR Title: Use `__repl_entry` prefix to shorten `shell_parse` stack traces BEFORE CODE: ```jldoctest julia> Base.rstrip_shell("echo 'Hello World' \\ ") "echo 'Hello World' \\ " julia> Base.rstrip_shell("echo 'Hello World' ") "echo 'Hello World...
```suggestion # N.B.: Any functions starting with __repl_entry cut off backtraces when printing in the REPL. function __repl_entry_shell_parse(str::AbstractString, interpolate::Bool, special::AbstractString, filename) ``` Elsewhere we have this comment, which is very helpful as function names are typically not sema...
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.unreference_module(Base64_key) finally oldBase64 === nothing || Base.register_root_module(oldBase64) copy!(DEPOT_PATH, original_depot_path) try # don't error if removing depot failed rm(depot_path, force=true, recursive=true) catch end end end @te...
Actually #60392 would manifest as an error in the `require_stdlib` call, not here ```suggestion Base.maybe_root_module(REPLExt_pkgid) isa Module || error("Something is wrong") ```
Base.unreference_module(Base64_key) finally oldBase64 === nothing || Base.register_root_module(oldBase64) copy!(DEPOT_PATH, original_depot_path) try # don't error if removing depot failed rm(depot_path, force=true, recursive=true) catch end end end @te...
@@ -1639,3 +1639,22 @@ end end end end +@testset "require_stdlib extension with non-stdlib from module" begin + # Test that require_stdlib doesn't error when called with an extension + # and the `from` module is not from the bundled depot (from_stdlib=false path) + # This is a regression test fo...
test/loading.jl
26
Julia
0.857
bug
187
29
29
false
[release-1.11] Fix KeyError in require_stdlib for non-stdlib extensions
60,491
JuliaLang/julia
35,573
Julia
IanButterworth
IanButterworth
Review this pull request change. Language: Julia File: test/loading.jl PR Title: [release-1.11] Fix KeyError in require_stdlib for non-stdlib extensions BEFORE CODE: Base.unreference_module(Base64_key) finally oldBase64 === nothing || Base.register_root_module(oldBase64) copy!(DEPOT_PAT...
Actually #60392 would manifest as an error in the `require_stdlib` call, not here ```suggestion Base.maybe_root_module(REPLExt_pkgid) isa Module || error("Something is wrong") ```
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.gc_bytes(b0) @noinline f(args...) Base.gc_bytes(b1) return b1[] - b0[] 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...
```suggestion sa = String(ex.args[1]::Symbol) ```
Base.gc_bytes(b0) @noinline f(args...) Base.gc_bytes(b1) return b1[] - b0[] 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...
@@ -539,6 +539,14 @@ function is_simply_call(@nospecialize ex) Meta.isexpr(a, :..., 1) && is_simple_atom(a.args[1]) && continue return false end + # Ensure Expr(:call, .+, ...) get wrapped + if ex.args[1] isa Symbol + sa = String(ex.args[1])
base/timing.jl
26
Julia
0.571
suggestion
59
51
51
false
Fix `@allocated 1 .+ 1`
60,494
JuliaLang/julia
35,573
Julia
aviatesk
N5N3
Review this pull request change. Language: Julia File: base/timing.jl PR Title: Fix `@allocated 1 .+ 1` BEFORE CODE: Base.gc_bytes(b0) @noinline f(args...) Base.gc_bytes(b1) return b1[] - b0[] end only(methods(allocated)).called = 0xff @constprop :none function allocations(f, args::Vararg{Any,N}) w...
```suggestion sa = String(ex.args[1]::Symbol) ```
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 Base.MathConstants using Random using LinearAlgebra using Test const ≣ = isequal # convenient for comparing NaNs @testset "basic booleans" begin @test true @test !false @test !!true @test !!!false @test true ==...
Avoid unrelated change? ```suggestion ```
# This file is a part of Julia. License is MIT: https://julialang.org/license using Base.MathConstants using Random using LinearAlgebra using Test const ≣ = isequal # convenient for comparing NaNs @testset "basic booleans" begin @test true @test !false @test !!true @test !!!false @test true == ...
@@ -4,6 +4,8 @@ using Base.MathConstants using Random using LinearAlgebra +using Test +
test/numbers.jl
7
Julia
0.5
suggestion
42
32
32
false
Fix incorrect results from floating-point division (fld, cld, div)
60,497
JuliaLang/julia
35,573
Julia
nsajko
lvlte
Review this pull request change. Language: Julia File: test/numbers.jl PR Title: Fix incorrect results from floating-point division (fld, cld, div) BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license using Base.MathConstants using Random using LinearAlgebra using Test const...
Avoid unrelated change? ```suggestion ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
julia> div(4, 3, RoundDown) # Matches fld(4, 3) 1 julia> div(4, 3, RoundUp) # Matches cld(4, 3) 2 julia> div(5, 2, RoundNearest) 2 julia> div(5, 2, RoundNearestTiesAway) 3 julia> div(-5, 2, RoundNearest) -2 julia> div(-5, 2, RoundNearestTiesAway) -3 julia> div(-5, 2, RoundNearestTiesUp) -2 julia> div(4, 3, RoundFromZer...
I know this is wording taken from the original docstring, but, if possible, I think we could find a more descriptive / less opinionated word than "correct" here. if we do use the word "correct," I think the responsibility is on us to be very pedantic / technical / precise about what we mean by correctness
julia> div(4, 3, RoundDown) # Matches fld(4, 3) 1 julia> div(4, 3, RoundUp) # Matches cld(4, 3) 2 julia> div(5, 2, RoundNearest) 2 julia> div(5, 2, RoundNearestTiesAway) 3 julia> div(-5, 2, RoundNearest) -2 julia> div(-5, 2, RoundNearestTiesAway) -3 julia> div(-5, 2, RoundNearestTiesUp) -2 julia> div(4, 3, RoundFromZer...
@@ -43,21 +43,27 @@ julia> div(4, 3, RoundFromZero) julia> div(-4, 3, RoundFromZero) -2 ``` -Because `div(x, y)` implements strictly correct truncated rounding based on the true -value of floating-point numbers, unintuitive situations can arise. For example: -```jldoctest -julia> div(6.0, 0.1) -59.0 -julia> 6.0 / 0....
base/div.jl
26
Julia
0.5
nitpick
306
51
51
false
Fix incorrect results from floating-point division (fld, cld, div)
60,497
JuliaLang/julia
35,573
Julia
adienes
lvlte
Review this pull request change. Language: Julia File: base/div.jl PR Title: Fix incorrect results from floating-point division (fld, cld, div) BEFORE CODE: julia> div(4, 3, RoundDown) # Matches fld(4, 3) 1 julia> div(4, 3, RoundUp) # Matches cld(4, 3) 2 julia> div(5, 2, RoundNearest) 2 julia> div(5, 2, RoundNeares...
I know this is wording taken from the original docstring, but, if possible, I think we could find a more descriptive / less opinionated word than "correct" here. if we do use the word "correct," I think the responsibility is on us to be very pedantic / technical / precise about what we mean by correctness
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.
elseif occursin(r"^ {0,3}\d+(\.|\))( |$)", bullet) # An ordered list. Either with `1. ` or `1) ` style numbering. r = occursin(".", bullet) ? r"^ {0,3}(\d+)\.( |$)" : r"^ {0,3}(\d+)\)( |$)" Base.parse(Int, (match(r, bullet)::AbstractMatch).captures[1]), r ...
Please put a space after `#` to follow the style of the surrounding code. Also: typo :-) ```suggestion # Skip any additional blank lines and check indentation ```
elseif occursin(r"^ {0,3}\d+(\.|\))( |$)", bullet) # An ordered list. Either with `1. ` or `1) ` style numbering. r = occursin(".", bullet) ? r"^ {0,3}(\d+)\.( |$)" : r"^ {0,3}(\d+)\)( |$)" Base.parse(Int, (match(r, bullet)::AbstractMatch).captures[1]), r ...
@@ -292,9 +292,32 @@ function list(stream::IO, block::MD) while !eof(stream) if startswith(stream, "\n") if newline - # Double newline ends the current list. - pushitem!(list, buffer) - break + # We have a...
stdlib/Markdown/src/Common/block.jl
26
Julia
0.714
suggestion
185
51
51
false
Markdown: inside a list, fix code blocks containing multiple consecutive empty lines
60,502
JuliaLang/julia
35,573
Julia
fingolfin
phantomsoldierking
Review this pull request change. Language: Julia File: stdlib/Markdown/src/Common/block.jl PR Title: Markdown: inside a list, fix code blocks containing multiple consecutive empty lines BEFORE CODE: elseif occursin(r"^ {0,3}\d+(\.|\))( |$)", bullet) # An ordered list. Either with `1. ` o...
Please put a space after `#` to follow the style of the surrounding code. Also: typo :-) ```suggestion # Skip any additional blank lines and check indentation ```
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.
newline = false # For checking if we have two consecutive newlines: end of list. count = 0 # Count of list items. Used to check if we need to push remaining # content in `buffer` after leaving the `while` loop. while !eof(stream) if startswit...
```suggestion # Multiple blank lines within indented content - allow it ```
newline = false # For checking if we have two consecutive newlines: end of list. count = 0 # Count of list items. Used to check if we need to push remaining # content in `buffer` after leaving the `while` loop. while !eof(stream) if startswit...
@@ -292,9 +292,32 @@ function list(stream::IO, block::MD) while !eof(stream) if startswith(stream, "\n") if newline - # Double newline ends the current list. - pushitem!(list, buffer) - break + # We have a...
stdlib/Markdown/src/Common/block.jl
26
Julia
0.714
suggestion
101
51
51
false
Markdown: inside a list, fix code blocks containing multiple consecutive empty lines
60,502
JuliaLang/julia
35,573
Julia
fingolfin
phantomsoldierking
Review this pull request change. Language: Julia File: stdlib/Markdown/src/Common/block.jl PR Title: Markdown: inside a list, fix code blocks containing multiple consecutive empty lines BEFORE CODE: newline = false # For checking if we have two consecutive newlines: end of list. count = 0 ...
```suggestion # Multiple blank lines within indented content - allow 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.
- item domaths(x::Number) = x + 5 domath(x::Int) = x + 10 """ # Parse Markdown normally md = Markdown.parse(input) # Convert to HTML html = sprint(show, MIME"text/html"(), md) # Must still be a single list item @test occursin("<ul>", html) @test occursin("<li>",...
But this test also passes with the *current* version of the code. You are not actually testing that your change does something! I would recommend to just test the full HTML output as is done e.g. in line 1122 and in other places. That then also will catch other (intended or unintended) changes affecting this output.
md = Markdown.parse(""" - code block inside a list with more than one blank line with indentation works ```julia domaths(x::Number) = x + 5 domath(x::Int) = x + 10 ``` - another entry, now testing code blocks without fences # this is a code block x = 1 + 1 ...
@@ -1354,6 +1354,36 @@ end @test insert_hlines(nothing) === nothing end +@testset "issue: #59967: indented code blocks with more than one blank line" begin + input = """ + - item + + domaths(x::Number) = x + 5 + + + domath(x::Int) = x + 10 + """ + + # Parse Markdown normally + md = ...
stdlib/Markdown/test/runtests.jl
26
Julia
0.5
suggestion
320
32
51
false
Markdown: inside a list, fix code blocks containing multiple consecutive empty lines
60,502
JuliaLang/julia
35,573
Julia
fingolfin
phantomsoldierking
Review this pull request change. Language: Julia File: stdlib/Markdown/test/runtests.jl PR Title: Markdown: inside a list, fix code blocks containing multiple consecutive empty lines BEFORE CODE: - item domaths(x::Number) = x + 5 domath(x::Int) = x + 10 """ # Parse Markdown normally ...
But this test also passes with the *current* version of the code. You are not actually testing that your change does something! I would recommend to just test the full HTML output as is done e.g. in line 1122 and in other places. That then also will catch other (intended or unintended) changes affecting this 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.
end @testset "issue #42139: autolink" begin # ok @test md"<mailto:foo@bar.com>" |> html == """<p><a href="mailto:foo@bar.com">mailto:foo@bar.com</a></p>\n""" # not ok @test md"<mailto foo@bar.com>" |> html == """<p>&lt;mailto foo@bar.com&gt;</p>\n""" # see issue #42139 @test md"<一轮红日初升>" |> htm...
While it doesn't matter for the effectiveness of the test, let's still avoid a potentially confusing message: multiple blank lines now *do* work. Also, it is "indentation" not "indention". ```suggestion - code block inside a list with more than one blank line with indentation works ```
end @testset "issue #42139: autolink" begin # ok @test md"<mailto:foo@bar.com>" |> html == """<p><a href="mailto:foo@bar.com">mailto:foo@bar.com</a></p>\n""" # not ok @test md"<mailto foo@bar.com>" |> html == """<p>&lt;mailto foo@bar.com&gt;</p>\n""" # see issue #42139 @test md"<一轮红日初升>" |> htm...
@@ -1354,6 +1354,32 @@ end @test insert_hlines(nothing) === nothing end +@testset "#59967: indented code blocks with more than one blank line" begin + # Test the broken case in issue: indented code block with multiple blank lines + md = Markdown.parse(""" +- code block with more than one blank line with i...
stdlib/Markdown/test/runtests.jl
26
Julia
0.857
suggestion
289
51
51
false
Markdown: inside a list, fix code blocks containing multiple consecutive empty lines
60,502
JuliaLang/julia
35,573
Julia
fingolfin
phantomsoldierking
Review this pull request change. Language: Julia File: stdlib/Markdown/test/runtests.jl PR Title: Markdown: inside a list, fix code blocks containing multiple consecutive empty lines BEFORE CODE: end @testset "issue #42139: autolink" begin # ok @test md"<mailto:foo@bar.com>" |> html == """<p><a href="mailt...
While it doesn't matter for the effectiveness of the test, let's still avoid a potentially confusing message: multiple blank lines now *do* work. Also, it is "indentation" not "indention". ```suggestion - code block inside a list with more than one blank line with indentation works ```
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 isempty(Docs.undocumented_names(Markdown)) end @testset "Non-Markdown" begin # https://github.com/JuliaLang/julia/issues/37765 @test isa(insert_hlines(Text("foo")), Text) # https://github.com/JuliaLang/julia/issues/37757 @test insert_hlines(nothing) === nothing end @testset "#59967: indented...
```suggestion <li><p> code block inside a list with more than one blank line with indentation works</p> ```
@test isempty(Docs.undocumented_names(Markdown)) end @testset "Non-Markdown" begin # https://github.com/JuliaLang/julia/issues/37765 @test isa(insert_hlines(Text("foo")), Text) # https://github.com/JuliaLang/julia/issues/37757 @test insert_hlines(nothing) === nothing end @testset "#59967: indented...
@@ -1354,6 +1354,32 @@ end @test insert_hlines(nothing) === nothing end +@testset "#59967: indented code blocks with more than one blank line" begin + # Test the broken case in issue: indented code block with multiple blank lines + md = Markdown.parse(""" +- code block with more than one blank line with i...
stdlib/Markdown/test/runtests.jl
26
Julia
0.714
suggestion
117
40
51
false
Markdown: inside a list, fix code blocks containing multiple consecutive empty lines
60,502
JuliaLang/julia
35,573
Julia
fingolfin
phantomsoldierking
Review this pull request change. Language: Julia File: stdlib/Markdown/test/runtests.jl PR Title: Markdown: inside a list, fix code blocks containing multiple consecutive empty lines BEFORE CODE: @test isempty(Docs.undocumented_names(Markdown)) end @testset "Non-Markdown" begin # https://github.com/JuliaLa...
```suggestion <li><p> code block inside a list with more than one blank line with indentation works</p> ```
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.
# see issue #42139 @test md"<一轮红日初升>" |> html == """<p>&lt;一轮红日初升&gt;</p>\n""" end @testset "Docstrings" begin @test isempty(Docs.undocumented_names(Markdown)) end @testset "Non-Markdown" begin # https://github.com/JuliaLang/julia/issues/37765 @test isa(insert_hlines(Text("foo")), Text) # http...
Your test currently only tests the "positive" case: that the list is not ended prematurely. But I think we should also verify that it still ends when it should end. How about adding something like this: ```suggestion - another entry, now testing code blocks without fences # this is a code block x = 1 ...
# see issue #42139 @test md"<一轮红日初升>" |> html == """<p>&lt;一轮红日初升&gt;</p>\n""" end @testset "Docstrings" begin @test isempty(Docs.undocumented_names(Markdown)) end @testset "Non-Markdown" begin # https://github.com/JuliaLang/julia/issues/37765 @test isa(insert_hlines(Text("foo")), Text) # http...
@@ -1354,6 +1354,32 @@ end @test insert_hlines(nothing) === nothing end +@testset "#59967: indented code blocks with more than one blank line" begin + # Test the broken case in issue: indented code block with multiple blank lines + md = Markdown.parse(""" +- code block with more than one blank line with i...
stdlib/Markdown/test/runtests.jl
26
Julia
0.857
suggestion
998
45
51
false
Markdown: inside a list, fix code blocks containing multiple consecutive empty lines
60,502
JuliaLang/julia
35,573
Julia
fingolfin
phantomsoldierking
Review this pull request change. Language: Julia File: stdlib/Markdown/test/runtests.jl PR Title: Markdown: inside a list, fix code blocks containing multiple consecutive empty lines BEFORE CODE: # see issue #42139 @test md"<一轮红日初升>" |> html == """<p>&lt;一轮红日初升&gt;</p>\n""" end @testset "Docstrings" begin ...
Your test currently only tests the "positive" case: that the list is not ended prematurely. But I think we should also verify that it still ends when it should end. How about adding something like this: ```suggestion - another entry, now testing code blocks without fences # this is a code block x = 1 ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
print(io, ' '^margin, styled"{$accent,markdown_admonition:│}", line) i < length(lines) && println(io) end end function term(io::IO, f::Footnote, columns) print(io, ' '^margin, "│ ") print(io, styled"{markdown_footnote:[^$(f.id)]}") println(io, '\n', ' '^margin, '│') content = annotp...
This line change is fixing the handling of list starting at e.g. `999.`
print(io, ' '^margin, styled"{$accent,markdown_admonition:│}", line) i < length(lines) && println(io) end end function term(io::IO, f::Footnote, columns) print(io, ' '^margin, "│ ") print(io, styled"{markdown_footnote:[^$(f.id)]}") println(io, '\n', ' '^margin, '│') content = annotp...
@@ -70,30 +70,40 @@ function term(io::IO, f::Footnote, columns) end end -const _list_bullets = ("• ", "– ", "▪ ") +const _list_bullets = ("• ", "– ", "▪ ") function term(io::IO, md::List, columns, depth::Int = 1) dterm(io, md, columns, _depth) = term(io, md, columns) dterm(io, md::List, col...
stdlib/Markdown/src/render/terminal/render.jl
26
Julia
0.429
suggestion
71
51
51
false
Improve rendering Markdown lists in a terminal
60,519
JuliaLang/julia
35,573
Julia
fingolfin
fingolfin
Review this pull request change. Language: Julia File: stdlib/Markdown/src/render/terminal/render.jl PR Title: Improve rendering Markdown lists in a terminal BEFORE CODE: print(io, ' '^margin, styled"{$accent,markdown_admonition:│}", line) i < length(lines) && println(io) end end function term(...
This line change is fixing the handling of list starting at e.g. `999.`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for (i, line) in enumerate(lines) print(io, ' '^margin, '│', line) i < length(lines) && println(io) end end const _list_bullets = ("• ", "– ", "▪ ") function term(io::IO, md::List, columns, depth::Int = 1) dterm(io, md, columns, _depth) = term(io, md, columns) dterm(io, md::Lis...
This replaces the hardcoded `columns - 10` below to fix the word wrapping
for (i, line) in enumerate(lines) print(io, ' '^margin, '│', line) i < length(lines) && println(io) end end const _list_bullets = ("• ", "– ", "▪ ") function term(io::IO, md::List, columns, depth::Int = 1) dterm(io, md, columns, _depth) = term(io, md, columns) dterm(io, md::List, ...
@@ -70,30 +70,40 @@ function term(io::IO, f::Footnote, columns) end end -const _list_bullets = ("• ", "– ", "▪ ") +const _list_bullets = ("• ", "– ", "▪ ") function term(io::IO, md::List, columns, depth::Int = 1) dterm(io, md, columns, _depth) = term(io, md, columns) dterm(io, md::List, col...
stdlib/Markdown/src/render/terminal/render.jl
26
Julia
0.429
suggestion
73
51
51
false
Improve rendering Markdown lists in a terminal
60,519
JuliaLang/julia
35,573
Julia
fingolfin
fingolfin
Review this pull request change. Language: Julia File: stdlib/Markdown/src/render/terminal/render.jl PR Title: Improve rendering Markdown lists in a terminal BEFORE CODE: for (i, line) in enumerate(lines) print(io, ' '^margin, '│', line) i < length(lines) && println(io) end end const _list_...
This replaces the hardcoded `columns - 10` below to fix the word wrapping
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 (jl_is_symbol(ex)) { JL_GC_POP(); return jl_eval_global_var(m, (jl_sym_t*)ex, ct->world_age); } else if (head == NULL) { JL_GC_POP(); return (jl_value_t*)ex; } int has_ccall = 0, has_defs = 0, has_loops = 0, has_opaque = 0, forced_compile = 0; asser...
Did the "scope" of this world change have to expand?
} jl_value_t *result = jl_eval_thunk(m, thk, fast); JL_GC_POP(); return result; } // Evaluate lowered IR thunk `thk` at top level in module `m` in the latest world JL_DLLEXPORT jl_value_t *jl_eval_thunk(jl_module_t *JL_NONNULL m, jl_code_info_t *thk, int fast) { jl_task_t *ct = jl_current_task; ...
@@ -717,17 +703,44 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_val JL_GC_POP(); return (jl_value_t*)ex; } - - int has_ccall = 0, has_defs = 0, has_loops = 0, has_opaque = 0, forced_compile = 0; assert(head == jl_thunk_sym); thk = (jl_code_info_t*)j...
src/toplevel.c
26
C
0.286
question
52
51
51
false
Move thunk and export evaluation out of `jl_toplevel_eval_flex`
60,528
JuliaLang/julia
35,573
Julia
topolarity
c42f
Review this pull request change. Language: C File: src/toplevel.c PR Title: Move thunk and export evaluation out of `jl_toplevel_eval_flex` BEFORE CODE: } else if (jl_is_symbol(ex)) { JL_GC_POP(); return jl_eval_global_var(m, (jl_sym_t*)ex, ct->world_age); } else if (head == NULL) { ...
Did the "scope" of this world change have to expand?
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_value_t *throw_ex = (jl_value_t*)jl_exprn(jl_call_sym, 2); JL_GC_PUSH1(&throw_ex); jl_exprargset(throw_ex, 0, BUILTIN(throw)); jl_exprargset(throw_ex, 1, exc); jl_toplevel_eval_flex(m, throw_ex, 0, 0, &filename, &lineno); JL_GC_POP(); } // Format error message and call jl_eval static void ...
I don't know why we have this as `JL_MAYBE_UNROOTED`. This is a real bug though, so thanks for the fix!
{ jl_value_t *throw_ex = (jl_value_t*)jl_exprn(jl_call_sym, 2); JL_GC_PUSH1(&throw_ex); jl_exprargset(throw_ex, 0, BUILTIN(throw)); jl_exprargset(throw_ex, 1, exc); jl_toplevel_eval_flex(m, throw_ex, 0, 0, &filename, &lineno); JL_GC_POP(); } // Format error message and call jl_eval static void ...
@@ -568,12 +568,14 @@ JL_DLLEXPORT jl_binding_partition_t *jl_declare_constant_val2( jl_binding_t *b, jl_module_t *mod, jl_sym_t *var, jl_value_t *val, enum jl_partition_kind constant_kind) { + JL_GC_PUSH1(&val);
src/toplevel.c
26
C
0.643
bug
106
51
51
false
Move thunk and export evaluation out of `jl_toplevel_eval_flex`
60,528
JuliaLang/julia
35,573
Julia
topolarity
c42f
Review this pull request change. Language: C File: src/toplevel.c PR Title: Move thunk and export evaluation out of `jl_toplevel_eval_flex` BEFORE CODE: { jl_value_t *throw_ex = (jl_value_t*)jl_exprn(jl_call_sym, 2); JL_GC_PUSH1(&throw_ex); jl_exprargset(throw_ex, 0, BUILTIN(throw)); jl_exprargset(t...
I don't know why we have this as `JL_MAYBE_UNROOTED`. This is a real bug though, so thanks for the fix!
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 binding for reading JL_DLLEXPORT jl_binding_t *jl_get_binding(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var); JL_DLLEXPORT jl_value_t *jl_module_globalref(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var); JL_DLLEXPORT jl_value_t *jl_get_binding_type(jl_module_t *m, jl_sym_t *var); // get binding for assignme...
@vtjnash deleted this export in https://github.com/JuliaLang/julia/pull/57765/ I assume that was just part of the re-factor around handling the world counter lock correctly and not removed due to API concerns, but mentioning here just in case.
// get binding for reading JL_DLLEXPORT jl_binding_t *jl_get_binding(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var); JL_DLLEXPORT jl_value_t *jl_module_globalref(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var); JL_DLLEXPORT jl_value_t *jl_get_binding_type(jl_module_t *m, jl_sym_t *var); // get binding for assignme...
@@ -2048,7 +2048,7 @@ JL_DLLEXPORT jl_binding_partition_t *jl_declare_constant_val2(jl_binding_t *b JL JL_DLLEXPORT void jl_module_import(jl_task_t *ct, jl_module_t *to, jl_module_t *from, jl_sym_t *asname, jl_sym_t *s, int explici); JL_DLLEXPORT void jl_import_module(jl_task_t *ct, jl_module_t *m, jl_module_t *impor...
src/julia.h
26
C/C++
0.5
suggestion
246
51
51
false
Move thunk and export evaluation out of `jl_toplevel_eval_flex`
60,528
JuliaLang/julia
35,573
Julia
topolarity
c42f
Review this pull request change. Language: C/C++ File: src/julia.h PR Title: Move thunk and export evaluation out of `jl_toplevel_eval_flex` BEFORE CODE: // get binding for reading JL_DLLEXPORT jl_binding_t *jl_get_binding(jl_module_t *m JL_PROPAGATES_ROOT, jl_sym_t *var); JL_DLLEXPORT jl_value_t *jl_module_globalr...
@vtjnash deleted this export in https://github.com/JuliaLang/julia/pull/57765/ I assume that was just part of the re-factor around handling the world counter lock correctly and not removed due to API concerns, but mentioning here just in case.
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_GC_POP(); return (jl_value_t*)ex; } int has_ccall = 0, has_defs = 0, has_loops = 0, has_opaque = 0, forced_compile = 0; assert(head == jl_thunk_sym); thk = (jl_code_info_t*)jl_exprarg(ex, 0); if (!jl_is_code_info(thk) || !jl_typetagis(thk->code, jl_array_any_type)) { jl_e...
`jl_resolve_definition_effects_in_ir` has side effects, so this seems should be mandatory to appear afterwards (sorry about being so slow to post-review this)
// Evaluate lowered IR thunk `thk` at top level in module `m` in the latest world JL_DLLEXPORT jl_value_t *jl_eval_thunk(jl_module_t *JL_NONNULL m, jl_code_info_t *thk, int fast) { jl_task_t *ct = jl_current_task; JL_TYPECHK(jl_eval_thunk, code_info, (jl_value_t*)thk); JL_TYPECHK(jl_eval_thunk, array_any, ...
@@ -738,25 +751,22 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_val mfunc = jl_method_instance_for_thunk(thk, m); jl_resolve_definition_effects_in_ir((jl_array_t*)thk->code, m, NULL, NULL, 0); // Don't infer blocks containing e.g. method definitions, since i...
src/toplevel.c
26
C
0.571
performance
158
51
51
false
Move thunk and export evaluation out of `jl_toplevel_eval_flex`
60,528
JuliaLang/julia
35,573
Julia
vtjnash
c42f
Review this pull request change. Language: C File: src/toplevel.c PR Title: Move thunk and export evaluation out of `jl_toplevel_eval_flex` BEFORE CODE: JL_GC_POP(); return (jl_value_t*)ex; } int has_ccall = 0, has_defs = 0, has_loops = 0, has_opaque = 0, forced_compile = 0; assert(head...
`jl_resolve_definition_effects_in_ir` has side effects, so this seems should be mandatory to appear afterwards (sorry about being so slow to post-review this)
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.
_checkcontiguous(::Type{Bool}, A::AbstractArray) = false # `strides(A::DenseArray)` calls `size_to_strides` by default. # Thus it's OK to assume all `DenseArray`s are contiguously stored. _checkcontiguous(::Type{Bool}, A::DenseArray) = true _checkcontiguous(::Type{Bool}, A::ReshapedArray) = _checkcontiguous(Bool, paren...
I feel like these should be `cconvert(Ptr{S}, parent)` to actually match up the types, but oh well
byte_offset::Int cconv_parent::C end # Avoid unneeded nesting function _offset_cconvert(::Type{Ptr{T}}, byte_offset::Int, cconv_parent::OffsetCConvert{T}) where {T} _offset_cconvert( Ptr{T}, cconv_parent.byte_offset + byte_offset, cconv_parent.cconv_parent, ) end function _offse...
@@ -361,16 +361,54 @@ compute_offset1(parent::AbstractVector, stride1::Integer, I::Tuple{ReshapedRange substrides(strds::NTuple{N,Int}, I::Tuple{ReshapedUnitRange, Vararg{Any}}) where N = (size_to_strides(strds[1], size(I[1])...)..., substrides(tail(strds), tail(I))...) -# cconvert(::Type{<:Ptr}, V::SubArray{T,...
base/reshapedarray.jl
26
Julia
0.571
suggestion
98
49
51
false
Implement `cconvert` for `SubArray`
60,533
JuliaLang/julia
35,573
Julia
vtjnash
nhz2
Review this pull request change. Language: Julia File: base/reshapedarray.jl PR Title: Implement `cconvert` for `SubArray` BEFORE CODE: _checkcontiguous(::Type{Bool}, A::AbstractArray) = false # `strides(A::DenseArray)` calls `size_to_strides` by default. # Thus it's OK to assume all `DenseArray`s are contiguously ...
I feel like these should be `cconvert(Ptr{S}, parent)` to actually match up the types, but oh well
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.
depot_path = append_bundled_depot_path!(empty(DEPOT_PATH)) from_stdlib = true # set to false if `from` is a normal package so we do not want the internal loader for the extension either if ext isa String from_uuid = PkgId(from) from_m = get(loaded_modules, from_uuid, noth...
Why not reduce the `try-finally` to just this one function call?
try depot_path = append_bundled_depot_path!(empty(DEPOT_PATH)) from_stdlib = true # set to false if `from` is a normal package so we do not want the internal loader for the extension either if ext isa String from_uuid = PkgId(from) from_m = get(loaded_modules, from_uu...
@@ -2718,10 +2719,11 @@ function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}, fro set_pkgorigin_version_path(this_uuidkey, sourcepath) newm = start_loading(this_uuidkey, UInt128(0), true) newm === nothing || return newm + loading_started = true ...
base/loading.jl
26
Julia
0.357
question
64
51
51
false
[release-1.11] Backports for 1.11
60,549
JuliaLang/julia
35,573
Julia
topolarity
IanButterworth
Review this pull request change. Language: Julia File: base/loading.jl PR Title: [release-1.11] Backports for 1.11 BEFORE CODE: depot_path = append_bundled_depot_path!(empty(DEPOT_PATH)) from_stdlib = true # set to false if `from` is a normal package so we do not want the internal loader for the ext...
Why not reduce the `try-finally` to just this one function call?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
struct FinallyHandler{Attrs} tagvar::SyntaxTree{Attrs} target::JumpTarget{Attrs} exit_actions::Vector{Tuple{Symbol,Union{Nothing,SyntaxTree{Attrs}}}} end function FinallyHandler(tagvar::SyntaxTree{Attrs}, target::JumpTarget) where {Attrs} FinallyHandler{Attrs}(tagvar, target, Vector{Tuple{Symbo...
We may want a `Dict{IdTag, IdTag}` instead if I'm correct in thinking `var_id` is the only thing that changes. Remapping a node shouldn't change its provenance or other attributes
struct FinallyHandler{Attrs} tagvar::SyntaxTree{Attrs} target::JumpTarget{Attrs} exit_actions::Vector{Tuple{Symbol,Union{Nothing,SyntaxTree{Attrs}}}} end function FinallyHandler(tagvar::SyntaxTree{Attrs}, target::JumpTarget) where {Attrs} FinallyHandler{Attrs}(tagvar, target, Vector{Tuple{Symbo...
@@ -71,6 +71,7 @@ struct LinearIRContext{Attrs} <: AbstractLoweringContext next_label_id::Ref{Int} is_toplevel_thunk::Bool lambda_bindings::LambdaBindings + argmap::Dict{IdTag, SyntaxTree{Attrs}}
JuliaLowering/src/linear_ir.jl
26
Julia
0.571
suggestion
180
51
51
false
[JuliaLowering] Add remap for assigned-to arguments
60,551
JuliaLang/julia
35,573
Julia
mlechu
topolarity
Review this pull request change. Language: Julia File: JuliaLowering/src/linear_ir.jl PR Title: [JuliaLowering] Add remap for assigned-to arguments BEFORE CODE: struct FinallyHandler{Attrs} tagvar::SyntaxTree{Attrs} target::JumpTarget{Attrs} exit_actions::Vector{Tuple{Symbol,Union{Nothing,SyntaxTree{Att...
We may want a `Dict{IdTag, IdTag}` instead if I'm correct in thinking `var_id` is the only thing that changes. Remapping a node shouldn't change its provenance or other attributes
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.
is_single_assign::Bool is_maybe_undef::Bool is_called::Bool end function compile_lambda(outer_ctx, ex) lambda_args = ex[1] static_parameters = ex[2] ret_var = numchildren(ex) == 4 ? ex[4] : nothing lambda_bindings = ex.lambda_bindings ctx = LinearIRContext(outer_ctx, ex.is_toplevel_thun...
I wonder why flisp postpones this to after the `compile` call instead of just pushing the assignments first
name::String kind::Symbol is_nospecialize::Bool is_read::Bool is_single_assign::Bool is_maybe_undef::Bool is_called::Bool end function compile_lambda(outer_ctx, ex) lambda_args = ex[1] static_parameters = ex[2] ret_var = numchildren(ex) == 4 ? ex[4] : nothing lambda_bindings...
@@ -1057,10 +1066,23 @@ function compile_lambda(outer_ctx, ex) lambda_args = ex[1] static_parameters = ex[2] ret_var = numchildren(ex) == 4 ? ex[4] : nothing - # TODO: Add assignments for reassigned arguments to body lambda_bindings = ex.lambda_bindings ctx = LinearIRContext(outer_ctx, ex.is...
JuliaLowering/src/linear_ir.jl
26
Julia
0.571
suggestion
107
51
51
false
[JuliaLowering] Add remap for assigned-to arguments
60,551
JuliaLang/julia
35,573
Julia
mlechu
topolarity
Review this pull request change. Language: Julia File: JuliaLowering/src/linear_ir.jl PR Title: [JuliaLowering] Add remap for assigned-to arguments BEFORE CODE: is_single_assign::Bool is_maybe_undef::Bool is_called::Bool end function compile_lambda(outer_ctx, ex) lambda_args = ex[1] static_para...
I wonder why flisp postpones this to after the `compile` call instead of just pushing the assignments first
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
#include "julia.h" #include "julia_internal.h" #include "platform.h" #include "llvm-codegen-shared.h" #include "llvm-version.h" #include <stack> #include <queue> #include <tuple> // As of LLVM 13, there are two runtime JIT linker implementations, the older // RuntimeDyld (used via orc::RTDyldObjectLinkingLayer) and th...
Can you update this section as well?
#include "julia.h" #include "julia_internal.h" #include "platform.h" #include "llvm-codegen-shared.h" #include "llvm-version.h" #include <stack> #include <queue> #include <tuple> // As of LLVM 13, there are two runtime JIT linker implementations, the older // RuntimeDyld (used via orc::RTDyldObjectLinkingLayer) and th...
src/jitlayers.h
26
C/C++
0.071
question
36
51
51
false
Enable JITLink everywhere
60,576
JuliaLang/julia
35,573
Julia
vchuravy
xal-0
Review this pull request change. Language: C/C++ File: src/jitlayers.h PR Title: Enable JITLink everywhere BEFORE CODE: #include "julia.h" #include "julia_internal.h" #include "platform.h" #include "llvm-codegen-shared.h" #include "llvm-version.h" #include <stack> #include <queue> #include <tuple> // As of LLVM 13...
Can you update this section as well?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
#include "julia_assert.h" #include "julia.h" #include "julia_internal.h" #include "platform.h" #include "llvm-codegen-shared.h" #include "llvm-version.h" #include <stack> #include <queue> #include <tuple> // As of LLVM 13, there are two runtime JIT linker implementations, the older // RuntimeDyld (used via orc::RTDyld...
I suspect we could also drop oprofile support at this point.
#include "julia_assert.h" #include "julia.h" #include "julia_internal.h" #include "platform.h" #include "llvm-codegen-shared.h" #include "llvm-version.h" #include <stack> #include <queue> #include <tuple> // As of LLVM 13, there are two runtime JIT linker implementations, the older // RuntimeDyld (used via orc::RTDyld...
@@ -44,17 +44,18 @@ // aarch64-darwin (macOS on ARM64), and not likely to ever be supported there // (see https://bugs.llvm.org/show_bug.cgi?id=52029). // -// However, JITLink is a relatively young library and lags behind in platform -// and feature support (e.g. Windows, JITEventListeners for various profilers, -//...
src/jitlayers.h
26
C/C++
0.286
suggestion
61
51
51
false
Enable JITLink everywhere
60,576
JuliaLang/julia
35,573
Julia
vchuravy
xal-0
Review this pull request change. Language: C/C++ File: src/jitlayers.h PR Title: Enable JITLink everywhere BEFORE CODE: #include "julia_assert.h" #include "julia.h" #include "julia_internal.h" #include "platform.h" #include "llvm-codegen-shared.h" #include "llvm-version.h" #include <stack> #include <queue> #include...
I suspect we could also drop oprofile support at this point.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
x + y end (f_kw_closure(), f_kw_closure(x=5)) end """) == (11, 15) # Anonymous function syntax with `function` @test JuliaLowering.include_string(test_mod, """ begin local y = 2 call_it(function (x) x + y end, 3) end """) == 5 # Closure where static parameter is captured @test JuliaLowering.in...
Just to clarify: this test case failed previously.
function f_arg_if_branch2(x, cond) if cond x = 5 return ()->x end return x end # When original value is returned f_arg_if_branch2(100, false) end """) == 100 # Variable declared outside loop, assigned inside - needs Box (issue #37690) @test JuliaLowering....
@@ -241,4 +241,59 @@ method_ex = lower_str(test_mod, "Base.Experimental.@opaque x -> 2x").args[1].cod @test method_ex.args[1] === nothing @test method_ex.args[4] isa LineNumberNode +# Function where arguments are captured into closure and assigned (boxed) +@test JuliaLowering.include_string(test_mod, """ +begin + ...
JuliaLowering/test/closures.jl
26
Julia
0.214
bug
50
29
51
false
[JuliaLowering] Enrich closure tests and fix static parameter capture
60,577
JuliaLang/julia
35,573
Julia
aviatesk
aviatesk
Review this pull request change. Language: Julia File: JuliaLowering/test/closures.jl PR Title: [JuliaLowering] Enrich closure tests and fix static parameter capture BEFORE CODE: x + y end (f_kw_closure(), f_kw_closure(x=5)) end """) == (11, 15) # Anonymous function syntax with `function` @test Jul...
Just to clarify: this test case failed previously.
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 include("rich.jl") # Utils # Handle URI encoding, poorly. The code here was initially copied from # Base.Filesystem, then modified. The original code implements RFC3986 Section # 2.1 and 2.2. # # We changed encode_uri_component to not enc...
```suggestion # do *not* exclude '[' and ']' from percent encoding, even though they are in ```
# This file is a part of Julia. License is MIT: https://julialang.org/license include("rich.jl") # Utils # Handle URI encoding, poorly. The code here was initially copied from # Base.Filesystem, then modified. The original code implements RFC3986 Section # 2.1 and 2.2. # # We changed encode_uri_component to not enc...
@@ -4,12 +4,32 @@ include("rich.jl") # Utils + +# Handle URI encoding, poorly. The code here was initially copied from +# Base.Filesystem, then modified. The original code implements RFC3986 Section +# 2.1 and 2.2. +# +# We changed encode_uri_component to not encode characters declared as +# "reserved" by RFC3986 ...
stdlib/Markdown/src/render/html.jl
20
Julia
0.571
suggestion
97
45
45
false
Markdown: implement URI encoding
60,578
JuliaLang/julia
35,573
Julia
fingolfin
fingolfin
Review this pull request change. Language: Julia File: stdlib/Markdown/src/render/html.jl PR Title: Markdown: implement URI encoding BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license include("rich.jl") # Utils # Handle URI encoding, poorly. The code here was initially co...
```suggestion # do *not* exclude '[' and ']' from percent encoding, even though they are 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.
# Handle URI encoding, poorly. The code here was initially copied from # Base.Filesystem, then modified. The original code implements RFC3986 Section # 2.1 and 2.2. # # We changed encode_uri_component to not encode characters declared as # "reserved" by RFC3986 Section 2.2 (i.e., those from the gen-delims and # sub-de...
There shouldn't be any need to encode attribute names; indeed I am not sure this would even work correctly if it happens. But here we fully know all attribute names that are actually used (they all appear in this file), and none of them needs any encoding.
# Handle URI encoding, poorly. The code here was initially copied from # Base.Filesystem, then modified. The original code implements RFC3986 Section # 2.1 and 2.2. # # We changed encode_uri_component to not encode characters declared as # "reserved" by RFC3986 Section 2.2 (i.e., those from the gen-delims and # sub-de...
@@ -4,12 +4,32 @@ include("rich.jl") # Utils + +# Handle URI encoding, poorly. The code here was initially copied from +# Base.Filesystem, then modified. The original code implements RFC3986 Section +# 2.1 and 2.2. +# +# We changed encode_uri_component to not encode characters declared as +# "reserved" by RFC3986 ...
stdlib/Markdown/src/render/html.jl
26
Julia
0.5
suggestion
258
51
51
false
Markdown: implement URI encoding
60,578
JuliaLang/julia
35,573
Julia
fingolfin
fingolfin
Review this pull request change. Language: Julia File: stdlib/Markdown/src/render/html.jl PR Title: Markdown: implement URI encoding BEFORE CODE: # Handle URI encoding, poorly. The code here was initially copied from # Base.Filesystem, then modified. The original code implements RFC3986 Section # 2.1 and 2.2. # # ...
There shouldn't be any need to encode attribute names; indeed I am not sure this would even work correctly if it happens. But here we fully know all attribute names that are actually used (they all appear in this file), and none of them needs any encoding.
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.
#endif #ifdef COPY_STACKS if (jl_setjmp(lasttstate.copy_ctx.uc_mcontext, 0)) { #ifdef MIGRATE_TASKS ptls = lastt->ptls; #endif lastt->ctx.copy_ctx = NULL; sanitizer_finish_switch_fiber(&ptls->previous_task->ctx, &lastt->ctx); return; ...
```suggestion // let the gc figure that out next time it does a quick mark ```
#endif #ifdef COPY_STACKS if (jl_setjmp(lasttstate.copy_ctx.uc_mcontext, 0)) { #ifdef MIGRATE_TASKS ptls = lastt->ptls; #endif lastt->ctx.copy_ctx = NULL; sanitizer_finish_switch_fiber(&ptls->previous_task->ctx, &lastt->ctx); return; ...
@@ -499,6 +495,12 @@ JL_NO_ASAN static void ctx_switch(jl_task_t *lastt) lastt->ctx.ctx = &lasttstate.ctx; } } + // this task's stack or scope field could have been modified after + // it was marked by an incremental collection + // move the barrier back instead of walking the shadow...
src/task.c
26
C
0.571
suggestion
84
51
51
false
add wb_back on all task switch paths
60,617
JuliaLang/julia
35,573
Julia
JeffBezanson
vtjnash
Review this pull request change. Language: C File: src/task.c PR Title: add wb_back on all task switch paths BEFORE CODE: #endif #ifdef COPY_STACKS if (jl_setjmp(lasttstate.copy_ctx.uc_mcontext, 0)) { #ifdef MIGRATE_TASKS ptls = lastt->ptls; #endif lastt->ctx.copy_ctx = N...
```suggestion // let the gc figure that out next time it does a quick mark ```
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.
# a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # type promotion $op_fast(a::Number, b::Number, c::Number, xs::Number...) = $op_fast(p...
combine this with the method above
# a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # type promotion $op_fast(a::Number, b::Number, c::Number, xs::Number...) = $op_fast(p...
@@ -301,8 +301,13 @@ exp10_fast(x::Union{Float32,Float64}) = Base.Math.exp10_fast(x) z = y % Int32 z == y ? pow_fast(x, z) : x^y end -pow_fast(x::Float32, y::Integer) = x^y +@inline function pow_fast(x::Float32, y::Integer) + z = y % Int32 + z == y ? pow_fast(x, z) : x^y +end
base/fastmath.jl
26
Julia
0.071
suggestion
34
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
oscardssmith
Yashagarwal9798
Review this pull request change. Language: Julia File: base/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: # a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of ...
combine this with the method above
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # type promotion $op_fast(a::Number, b::Number, c::Number, xs::Number...) = $op_fast(p...
```suggestion @inline function pow_fast(x::Union{Float32, Float64}, y::Integer) z = y % Int32 z == y ? pow_fast(x, z) : x^y end ```
# a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # type promotion $op_fast(a::Number, b::Number, c::Number, xs::Number...) = $op_fast(p...
@@ -301,8 +301,13 @@ exp10_fast(x::Union{Float32,Float64}) = Base.Math.exp10_fast(x) z = y % Int32 z == y ? pow_fast(x, z) : x^y end -pow_fast(x::Float32, y::Integer) = x^y +@inline function pow_fast(x::Float32, y::Integer) + z = y % Int32 + z == y ? pow_fast(x, z) : x^y +end
base/fastmath.jl
26
Julia
0.714
suggestion
139
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
oscardssmith
Yashagarwal9798
Review this pull request change. Language: Julia File: base/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: # a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of ...
```suggestion @inline function pow_fast(x::Union{Float32, Float64}, y::Integer) z = y % Int32 z == y ? pow_fast(x, z) : x^y end ```
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 #53817 # Note that exponent -2^63 fails testing because of issue #53881 # Therefore we test with -(2^63-1). For Int == Int32 there is an analogue restriction. # See also PR #53860. if Int == Int64 @test @fastmath(2^-9223372036854775807) === 0.0 @test_throws DomainError @fastm...
also test that `@fastmath x^y` produces approximately correct results for Float32/Float16 for both exponents that fit and that don't fit within Int32.
# Issue #53817 # Note that exponent -2^63 fails testing because of issue #53881 # Therefore we test with -(2^63-1). For Int == Int32 there is an analogue restriction. # See also PR #53860. if Int == Int64 @test @fastmath(2^-9223372036854775807) === 0.0 @test_throws DomainError @fastm...
@@ -303,6 +303,17 @@ end @test @fastmath (1 + 1 / n) ^ 4503599627370496 ≈ ℯ end +# Test that x^2 is inlined to fmul for all float types (issue #60639) +@testset "pow_fast inlining for literal powers" begin
test/fastmath.jl
26
Julia
0.5
suggestion
151
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
oscardssmith
Yashagarwal9798
Review this pull request change. Language: Julia File: test/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: # Issue #53817 # Note that exponent -2^63 fails testing because of issue #53881 # Therefore we test with -(2^63-1). For Int == Int32 there is...
also test that `@fastmath x^y` produces approximately correct results for Float32/Float16 for both exponents that fit and that don't fit within Int32.
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.
($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # t...
`llvm.powi.f16.i32` exists ```julia-repl julia> pow_fast(x::Float32, y::Int32) = ccall("llvm.powi.f32.i32", llvmcall, Float32, (Float32, Int32), x, y) pow_fast (generic function with 1 method) julia> @inline pow_fast(x::Float16, y::Integer) = Float16(pow_fast(Float32(x), y)) pow_fast (generic function with 2 methods) ...
($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # t...
@@ -297,12 +297,13 @@ exp10_fast(x::Union{Float32,Float64}) = Base.Math.exp10_fast(x) # builtins -@inline function pow_fast(x::Float64, y::Integer) +@inline function pow_fast(x::Union{Float32,Float64}, y::Integer) z = y % Int32 z == y ? pow_fast(x, z) : x^y end -pow_fast(x::Float32, y::Integer) = x^y p...
base/fastmath.jl
26
Julia
0.786
suggestion
576
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
giordano
Yashagarwal9798
Review this pull request change. Language: Julia File: base/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: ($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for ...
`llvm.powi.f16.i32` exists ```julia-repl julia> pow_fast(x::Float32, y::Int32) = ccall("llvm.powi.f32.i32", llvmcall, Float32, (Float32, Int32), x, y) pow_fast (generic function with 1 method) julia> @inline pow_fast(x::Float16, y::Integer) = Float16(pow_fast(Float32(x), y)) pow_fast (generic function with 2 methods) ...
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.
($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # t...
```suggestion pow_fast(x::T, y::Int32) where T <: IEEEFloat = ccall("llvm.powi", llvmcall, T, (T, Int32), x, y) ```
($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int...) # to match many definitions, so we need to keep the number of # definitions down to avoid losing type information. # t...
@@ -297,12 +297,13 @@ exp10_fast(x::Union{Float32,Float64}) = Base.Math.exp10_fast(x) # builtins -@inline function pow_fast(x::Float64, y::Integer) +@inline function pow_fast(x::Union{Float16,Float32,Float64}, y::Integer) z = y % Int32 z == y ? pow_fast(x, z) : x^y end -pow_fast(x::Float32, y::Integer) ...
base/fastmath.jl
26
Julia
0.714
suggestion
115
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
oscardssmith
Yashagarwal9798
Review this pull request change. Language: Julia File: base/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: ($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for ...
```suggestion pow_fast(x::T, y::Int32) where T <: IEEEFloat = ccall("llvm.powi", llvmcall, T, (T, Int32), x, y) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
$op_fast(promote(x,y)...) # fall-back implementation that applies after promotion $op_fast(x::T,y::T) where {T<:Number} = $op(x,y) # note: these definitions must not cause a dispatch loop when +(a,b) is # not defined, and must only try to call 2-argument definitions, so ...
```suggestion @inline function pow_fast(x::T, y::Integer) where T <: Base.IEEEFloat ```
$op_fast(promote(x,y)...) # fall-back implementation that applies after promotion $op_fast(x::T,y::T) where {T<:Number} = $op(x,y) # note: these definitions must not cause a dispatch loop when +(a,b) is # not defined, and must only try to call 2-argument definitions, so ...
@@ -297,12 +297,11 @@ exp10_fast(x::Union{Float32,Float64}) = Base.Math.exp10_fast(x) # builtins -@inline function pow_fast(x::Float64, y::Integer) +@inline function pow_fast(x::T, y::Integer) where T <: IEEEFloat
base/fastmath.jl
26
Julia
0.571
suggestion
87
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
oscardssmith
Yashagarwal9798
Review this pull request change. Language: Julia File: base/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: $op_fast(promote(x,y)...) # fall-back implementation that applies after promotion $op_fast(x::T,y::T) where {T<:Number} = $op...
```suggestion @inline function pow_fast(x::T, y::Integer) where T <: Base.IEEEFloat ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# not defined, and must only try to call 2-argument definitions, so # that defining +(a,b) is sufficient for full functionality. ($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int.....
```suggestion pow_fast(x::T, y::Int32) where T <: Base.IEEEFloat = ccall("llvm.powi", llvmcall, T, (T, Int32), x, y) ```
# not defined, and must only try to call 2-argument definitions, so # that defining +(a,b) is sufficient for full functionality. ($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int.....
@@ -297,12 +297,11 @@ exp10_fast(x::Union{Float32,Float64}) = Base.Math.exp10_fast(x) # builtins -@inline function pow_fast(x::Float64, y::Integer) +@inline function pow_fast(x::T, y::Integer) where T <: IEEEFloat z = y % Int32 z == y ? pow_fast(x, z) : x^y end -pow_fast(x::Float32, y::Integer) = x^y -p...
base/fastmath.jl
26
Julia
0.714
suggestion
120
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
oscardssmith
Yashagarwal9798
Review this pull request change. Language: Julia File: base/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: # not defined, and must only try to call 2-argument definitions, so # that defining +(a,b) is sufficient for full functionality. ...
```suggestion pow_fast(x::T, y::Int32) where T <: Base.IEEEFloat = ccall("llvm.powi", llvmcall, T, (T, Int32), x, y) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# not defined, and must only try to call 2-argument definitions, so # that defining +(a,b) is sufficient for full functionality. ($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int.....
```suggestion pow_fast(x::Float16, y::Int32) = ccall("llvm.powi", llvmcall, Float16, (Float16, Int32), x, y) pow_fast(x::Float32, y::Int32) = ccall("llvm.powi", llvmcall, Float32, (Float32, Int32), x, y) pow_fast(x::Float64, y::Int32) = ccall("llvm.powi", llvmcall, Float64, (Float64, Int32), x, y) ```
# not defined, and must only try to call 2-argument definitions, so # that defining +(a,b) is sufficient for full functionality. ($op_fast)(a, b, c, xs...) = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...)) # a further concern is that it's easy for a type like (Int,Int.....
@@ -297,12 +297,11 @@ exp10_fast(x::Union{Float32,Float64}) = Base.Math.exp10_fast(x) # builtins -@inline function pow_fast(x::Float64, y::Integer) +@inline function pow_fast(x::T, y::Integer) where T <: Base.IEEEFloat z = y % Int32 z == y ? pow_fast(x, z) : x^y end -pow_fast(x::Float32, y::Integer) = x...
base/fastmath.jl
26
Julia
0.786
suggestion
302
51
51
false
Fix `@fastmath x^2` inlining regression for `Float32` and `Float16`
60,640
JuliaLang/julia
35,573
Julia
oscardssmith
Yashagarwal9798
Review this pull request change. Language: Julia File: base/fastmath.jl PR Title: Fix `@fastmath x^2` inlining regression for `Float32` and `Float16` BEFORE CODE: # not defined, and must only try to call 2-argument definitions, so # that defining +(a,b) is sufficient for full functionality. ...
```suggestion pow_fast(x::Float16, y::Int32) = ccall("llvm.powi", llvmcall, Float16, (Float16, Int32), x, y) pow_fast(x::Float32, y::Int32) = ccall("llvm.powi", llvmcall, Float32, (Float32, Int32), x, y) pow_fast(x::Float64, y::Int32) = ccall("llvm.powi", llvmcall, Float64, (Float64, Int32), x, y) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
size_t catch_ip = jl_enternode_catch_dest(stmt); if (catch_ip) { catch_ip -= 1; while (catch_ip < ns) { jl_value_t *phicnode = jl_array_ptr_ref(stmts, catch_ip); if (!jl_is_phicnode(phicnode)) break; ...
This comment is now out of date. While updating it, can you explain in this comment why we don't need to preserve the new scope, since this was clearly confusing when it was originally written and to readers now? Maybe something like this? ```suggestion // GC preserve the old_scope, since it is not r...
size_t catch_ip = jl_enternode_catch_dest(stmt); if (catch_ip) { catch_ip -= 1; while (catch_ip < ns) { jl_value_t *phicnode = jl_array_ptr_ref(stmts, catch_ip); if (!jl_is_phicnode(phicnode)) break; ...
@@ -539,12 +539,14 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip, } s->locals[jl_source_nslots(s->src) + ip] = jl_box_ulong(jl_excstack_state(ct)); if (jl_enternode_scope(stmt)) { - jl_value_t *scope = eval_value(jl_enternode_sco...
src/interpreter.c
26
C
0.929
suggestion
672
51
51
false
Preserve the scope across the exception handler
60,647
JuliaLang/julia
35,573
Julia
NHDaly
vchuravy
Review this pull request change. Language: C File: src/interpreter.c PR Title: Preserve the scope across the exception handler BEFORE CODE: size_t catch_ip = jl_enternode_catch_dest(stmt); if (catch_ip) { catch_ip -= 1; while (catch_ip < ns) { ...
This comment is now out of date. While updating it, can you explain in this comment why we don't need to preserve the new scope, since this was clearly confusing when it was originally written and to readers now? Maybe something like this? ```suggestion // GC preserve the old_scope, since it is not 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.
} ctx.builder.SetInsertPoint(tryblk); auto ehptr = emit_ptrgep(ctx, ct, offsetof(jl_task_t, eh)); ctx.builder.CreateAlignedStore(ehbuff, ehptr, ctx.types().alignof_ptr); } // For the two-arg version of :enter, twiddle the scope ...
Same comment on the comment - see below
} ctx.builder.SetInsertPoint(tryblk); auto ehptr = emit_ptrgep(ctx, ct, offsetof(jl_task_t, eh)); ctx.builder.CreateAlignedStore(ehbuff, ehptr, ctx.types().alignof_ptr); } // For the two-arg version of :enter, twiddle the scope ...
@@ -9732,12 +9733,13 @@ static jl_llvm_functions_t Value *scope_ptr = get_scope_field(ctx); LoadInst *current_scope = ctx.builder.CreateAlignedLoad(ctx.types().T_prjlvalue, scope_ptr, ctx.types().alignof_ptr); StoreInst *scope_store = ctx.builder.CreateAlignedStore(sco...
src/codegen.cpp
26
C++
0.071
suggestion
39
51
51
false
Preserve the scope across the exception handler
60,647
JuliaLang/julia
35,573
Julia
NHDaly
vchuravy
Review this pull request change. Language: C++ File: src/codegen.cpp PR Title: Preserve the scope across the exception handler BEFORE CODE: } ctx.builder.SetInsertPoint(tryblk); auto ehptr = emit_ptrgep(ctx, ct, offsetof(jl_task_t, eh)); ctx.builder.Cr...
Same comment on the comment - see below
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// of gc_preserve_end propagated through a control-flow joins as long as all incoming // agree about the preserve state. // // This is correct as-is anyway - it just means the scope lives longer than it needs to // i...
NAK on this, should be a comment to explain why it is unnecessary or a no-op `emit_self_task_wb` (like we have for the other cases where wbs are omitted as an optimization).
// of gc_preserve_end propagated through a control-flow joins as long as all incoming // agree about the preserve state. // // This is correct as-is anyway - it just means the scope lives longer than it needs to // i...
@@ -6447,6 +6447,7 @@ static void emit_stmtpos(jl_codectx_t &ctx, jl_value_t *expr, int ssaval_result) Value *scope_ptr = get_scope_field(ctx); jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_gcframe).decorateInst( ctx.builder.CreateAlignedStore(scope_to_restore, scope_ptr, ctx....
src/codegen.cpp
26
C++
0.571
suggestion
173
51
51
false
Preserve the scope across the exception handler
60,647
JuliaLang/julia
35,573
Julia
Keno
vchuravy
Review this pull request change. Language: C++ File: src/codegen.cpp PR Title: Preserve the scope across the exception handler BEFORE CODE: // of gc_preserve_end propagated through a control-flow joins as long as all incoming // agree about the preserve state. ...
NAK on this, should be a comment to explain why it is unnecessary or a no-op `emit_self_task_wb` (like we have for the other cases where wbs are omitted as an optimization).
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_value_t *phicnode = jl_array_ptr_ref(stmts, catch_ip); if (!jl_is_phicnode(phicnode)) break; jl_array_t *values = (jl_array_t*)jl_fieldref_noalloc(phicnode, 0); for (size_t i = 0; i < jl_array_nrows(values); ++i) ...
Should be a new `jl_gc_wb_task` or sth.
jl_value_t *phicnode = jl_array_ptr_ref(stmts, catch_ip); if (!jl_is_phicnode(phicnode)) break; jl_array_t *values = (jl_array_t*)jl_fieldref_noalloc(phicnode, 0); for (size_t i = 0; i < jl_array_nrows(values); ++i) ...
@@ -539,12 +539,14 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip, } s->locals[jl_source_nslots(s->src) + ip] = jl_box_ulong(jl_excstack_state(ct)); if (jl_enternode_scope(stmt)) { - jl_value_t *scope = eval_value(jl_enternode_sco...
src/interpreter.c
26
C
0.286
suggestion
39
51
51
false
Preserve the scope across the exception handler
60,647
JuliaLang/julia
35,573
Julia
Keno
vchuravy
Review this pull request change. Language: C File: src/interpreter.c PR Title: Preserve the scope across the exception handler BEFORE CODE: jl_value_t *phicnode = jl_array_ptr_ref(stmts, catch_ip); if (!jl_is_phicnode(phicnode)) break; ...
Should be a new `jl_gc_wb_task` or sth.
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.
// In a generational collector is used, this function walks over the fields of the // object specified by the second parameter (as defined by the data type in the third // parameter). If a field points to a young object, the first parameter is enqueued into the // remembered set of the calling thread. JL_DLLEXPORT void...
```suggestion // As an optimization, the current_task is explicitly added to the remset while it is running. // Upon deschedule, we conservatively move the write barrier into the young generation. // This allows the omission of write barriers for all GC roots on the current task stack (JL_GC_PUSH_*), // as well as ...
// In a generational collector is used, this function walks over the fields of the // object specified by the second parameter (as defined by the data type in the third // parameter). If a field points to a young object, the first parameter is enqueued into the // remembered set of the calling thread. JL_DLLEXPORT void...
@@ -285,6 +285,11 @@ STATIC_INLINE void jl_gc_wb(const void *parent, const void *ptr) JL_NOTSAFEPOINT // can be used to annotate that a write barrier would be required were it not for this property // (as opposed to somebody just having forgotten to think about write barriers). STATIC_INLINE void jl_gc_wb_fresh(cons...
src/gc-interface.h
26
C/C++
0.857
suggestion
593
51
51
false
Preserve the scope across the exception handler
60,647
JuliaLang/julia
35,573
Julia
Keno
vchuravy
Review this pull request change. Language: C/C++ File: src/gc-interface.h PR Title: Preserve the scope across the exception handler BEFORE CODE: // In a generational collector is used, this function walks over the fields of the // object specified by the second parameter (as defined by the data type in the third //...
```suggestion // As an optimization, the current_task is explicitly added to the remset while it is running. // Upon deschedule, we conservatively move the write barrier into the young generation. // This allows the omission of write barriers for all GC roots on the current task stack (JL_GC_PUSH_*), // as well as ...
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.
ct->ctx.copy_stack = 1; ct->ctx.stkbuf = NULL; ct->ctx.bufsz = 0; } else { ct->ctx.copy_stack = 0; ct->ctx.stkbuf = stack; ct->ctx.bufsz = ssize; } #ifdef USE_TRACY char *unique_string = (char *)malloc(strlen("Root") + 1); strcpy(unique_string, "Root"...
Technically true, but also our practice is to omit this or _knownold annotations for jl_nothing.
ct->ctx.copy_stack = 1; ct->ctx.stkbuf = NULL; ct->ctx.bufsz = 0; } else { ct->ctx.copy_stack = 0; ct->ctx.stkbuf = stack; ct->ctx.bufsz = ssize; } #ifdef USE_TRACY char *unique_string = (char *)malloc(strlen("Root") + 1); strcpy(unique_string, "Root"...
@@ -1581,6 +1582,7 @@ jl_task_t *jl_init_root_task(jl_ptls_t ptls, void *stack_lo, void *stack_hi) ct->donenotify = jl_nothing; jl_atomic_store_relaxed(&ct->_isexception, 0); ct->scope = jl_nothing; + jl_gc_wb_fresh(ct, ct->scope);
src/task.c
26
C
0.214
suggestion
96
51
51
false
Preserve the scope across the exception handler
60,647
JuliaLang/julia
35,573
Julia
Keno
vchuravy
Review this pull request change. Language: C File: src/task.c PR Title: Preserve the scope across the exception handler BEFORE CODE: ct->ctx.copy_stack = 1; ct->ctx.stkbuf = NULL; ct->ctx.bufsz = 0; } else { ct->ctx.copy_stack = 0; ct->ctx.stkbuf = stack; ct->...
Technically true, but also our practice is to omit this or _knownold annotations for 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.
Value *loc; v = zext_struct(ctx, v); Align align(julia_alignment(typ)); if (valid_as_globalinit(v)) { // llvm can't handle all the things that could be inside a ConstantExpr assert(jl_is_concrete_type(typ)); // not legal to have an unboxed abstract type loc = get_pointer_to_constant(ctx....
Should be as simple as: ```c++ jl_datatype_t *dt = (jl_datatype_t *)v.typ; bool hasptr = dt->layout->first_ptr >= 0; size_t npointers = hasptr ? dt->layout->npointers : 0; auto InsertPoint = ctx.builder.saveIP(); ctx.builder.SetInsertPoint(ctx.topalloca->getParent(), ++ctx.topalloca->getIterat...
Value *loc; v = zext_struct(ctx, v); Align align(julia_alignment(typ)); if (valid_as_globalinit(v)) { // llvm can't handle all the things that could be inside a ConstantExpr assert(jl_is_concrete_type(typ)); // not legal to have an unboxed abstract type loc = get_pointer_to_constant(ctx....
@@ -2430,6 +2430,43 @@ static inline jl_cgval_t value_to_pointer(jl_codectx_t &ctx, const jl_cgval_t &v Align align(julia_alignment(v.typ)); Type *ty = julia_type_to_llvm(ctx, v.typ); AllocaInst *loc = emit_static_alloca(ctx, ty, align); + if (CountTrackedPointers(ty).count > 0) { + ...
src/codegen.cpp
26
C++
1
bug
995
51
51
false
Remove potential unitialized memory in the GC stack
60,651
JuliaLang/julia
35,573
Julia
topolarity
gbaraldi
Review this pull request change. Language: C++ File: src/codegen.cpp PR Title: Remove potential unitialized memory in the GC stack BEFORE CODE: Value *loc; v = zext_struct(ctx, v); Align align(julia_alignment(typ)); if (valid_as_globalinit(v)) { // llvm can't handle all the things that could be insi...
Should be as simple as: ```c++ jl_datatype_t *dt = (jl_datatype_t *)v.typ; bool hasptr = dt->layout->first_ptr >= 0; size_t npointers = hasptr ? dt->layout->npointers : 0; auto InsertPoint = ctx.builder.saveIP(); ctx.builder.SetInsertPoint(ctx.topalloca->getParent(), ++ctx.topalloca->getIterat...
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.
unalias_nodes(sl::SyntaxList) If a `SyntaxList` is given, every resulting tree will be unique with respect to each other as well as internally. A duplicate entry will produce a copied tree. """ unalias_nodes(st::SyntaxTree) = SyntaxTree( syntax_graph(st), _unalias_nodes(syntax_graph(st), st._id, Set{Node...
I'd be OK with turning this into an `@assert` (or just deleting it) Trying to compress edge ranges to overlap as a micro-optimization is kind of out there IMO.
unalias_nodes(sl::SyntaxList) If a `SyntaxList` is given, every resulting tree will be unique with respect to each other as well as internally. A duplicate entry will produce a copied tree. """ unalias_nodes(st::SyntaxTree) = SyntaxTree( syntax_graph(st), _unalias_nodes(syntax_graph(st), st._id, Set{NodeI...
@@ -740,6 +740,160 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +""" + unalias_nodes(st::SyntaxTree) + +Return a tree where each descendent of `st` has exactly one parent in `st`. The +returned tree is identical to `st` in all but underlying representation, where +every add...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.5
suggestion
162
51
51
false
SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!`
60,673
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!` BEFORE CODE: unalias_nodes(sl::SyntaxList) If a `SyntaxList` is given, every resulting tree will be unique with respect to each other a...
I'd be OK with turning this into an `@assert` (or just deleting it) Trying to compress edge ranges to overlap as a micro-optimization is kind of out there IMO.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
append!(graph.edges, children(graph, id)) graph.edge_ranges[id] = next_edge:lastindex(graph.edges) end union!(seen_edges, graph.edge_ranges[id]) push!(seen, id) for (c, i) in zip(children(graph, id), graph.edge_ranges[id]) c2 = _unalias_nodes(graph, c, seen, seen_edges) ...
```suggestion Provenance shrinkage: The green tree will be deleted unless specified in `keep`. ```
for (c, i) in zip(children(graph, id), graph.edge_ranges[id]) c2 = _unalias_nodes(graph, c, seen, seen_edges) # the new child should be the same in every way to the old one, so # modify the edge instead of triggering copies with `mapchildren` c !== c2 && (graph.edges[i] = c2) end...
@@ -740,6 +740,160 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +""" + unalias_nodes(st::SyntaxTree) + +Return a tree where each descendent of `st` has exactly one parent in `st`. The +returned tree is identical to `st` in all but underlying representation, where +every add...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.714
suggestion
100
51
51
false
SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!`
60,673
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!` BEFORE CODE: append!(graph.edges, children(graph, id)) graph.edge_ranges[id] = next_edge:lastindex(graph.edges) end u...
```suggestion Provenance shrinkage: The green tree will be deleted unless specified in `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.
end # Resolve provenance. Tricky to avoid dangling `.source` references. resolved_sources = Dict{NodeId, SourceAttrType}() # graph1 id => graph2 src function get_resolved!(id1::NodeId) out = get(resolved_sources, id1, nothing) if isnothing(out) src1 = graph1.source[id1] ...
Can this be done in iterative (worklist) style instead of recursive?
out = if haskey(map12, src1) map12[src1] elseif src1 isa NodeId get_resolved!(src1) elseif src1 isa Tuple map(get_resolved!, src1) else src1 end resolved_sources[id1] = out end...
@@ -740,6 +740,160 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +""" + unalias_nodes(st::SyntaxTree) + +Return a tree where each descendent of `st` has exactly one parent in `st`. The +returned tree is identical to `st` in all but underlying representation, where +every add...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.286
question
68
51
51
false
SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!`
60,673
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!` BEFORE CODE: end # Resolve provenance. Tricky to avoid dangling `.source` references. resolved_sources = Dict{NodeId, SourceAtt...
Can this be done in iterative (worklist) style instead of recursive?
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.
(graph1, entrypoints) = (unaliased.graph, unaliased.ids) nodes1 = copy(entrypoints) # Current reachable subset of graph1 map12 = Dict{NodeId, Int}() # graph1 => graph2 mapping graph2 = ensure_attributes!(SyntaxGraph(); attrdefs(graph1)...) while length(graph2.edge_ranges) < length(nodes1) ...
```suggestion attrval = get(graph1.attributes[attr], n1, nothing) if !isnothing(attrval) graph2.attributes[attr][n2] = attrval end ```
n2 = length(graph2.edge_ranges) + 1 n1 = nodes1[n2] map12[n1] = n2 push!(graph2.edge_ranges, is_leaf(graph1, n1) ? (0:-1) : (1:numchildren(graph1, n1)) .+ length(nodes1)) for c1 in children(graph1, n1) push!(nodes1, c1) end end graph2.edges...
@@ -740,6 +740,160 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +""" + unalias_nodes(st::SyntaxTree) + +Return a tree where each descendent of `st` has exactly one parent in `st`. The +returned tree is identical to `st` in all but underlying representation, where +every add...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.714
suggestion
191
51
51
false
SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!`
60,673
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!` BEFORE CODE: (graph1, entrypoints) = (unaliased.graph, unaliased.ids) nodes1 = copy(entrypoints) # Current reachable subset of ...
```suggestion attrval = get(graph1.attributes[attr], n1, nothing) if !isnothing(attrval) graph2.attributes[attr][n2] = attrval end ```
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 a tree where unreachable nodes (non-descendents of `st`) in its graph have been deleted, and where provenance data has been minimized. If `keep` is not nothing, also consider descendents of it reachable. It's usually useful to provide `keep=your_parser_output` (so we have expression provenance back to the...
Very naive question, but how does the GreenTree / provenance information interact with this? I would kind of naively expect to have a: 1. parsed syntax tree 2. lowered code tree but that the syntax tree does not get split just because of being referenced from multiple locations in the lowered code tree. Is ...
usually useful to provide `keep=your_parser_output` (so we have expression provenance back to the original parsed nodes, but no lowering-internal provenance.) In any case, we still retain byte (or, from old macros, LineNumberNode) provenance. Provenance shrinkage: The green tree will be deleted unless specified in `k...
@@ -740,6 +740,160 @@ function _copy_ast(graph2::SyntaxGraph, graph1::SyntaxGraph, return id2 end +""" + unalias_nodes(st::SyntaxTree) + +Return a tree where each descendent of `st` has exactly one parent in `st`. The +returned tree is identical to `st` in all but underlying representation, where +every add...
JuliaSyntax/src/porcelain/syntax_graph.jl
26
Julia
0.5
question
348
51
51
false
SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!`
60,673
JuliaLang/julia
35,573
Julia
topolarity
mlechu
Review this pull request change. Language: Julia File: JuliaSyntax/src/porcelain/syntax_graph.jl PR Title: SyntaxGraph utilities: `unalias_nodes`, `prune`, `annotate_parent!` BEFORE CODE: """ Return a tree where unreachable nodes (non-descendents of `st`) in its graph have been deleted, and where provenance data h...
Very naive question, but how does the GreenTree / provenance information interact with this? I would kind of naively expect to have a: 1. parsed syntax tree 2. lowered code tree but that the syntax tree does not get split just because of being referenced from multiple locations in the lowered code tree. 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 """ strptime([format], timestr) Parse a formatted time string into a `TmStruct` giving the seconds, minute, hour, date, etc. Supported formats are the same as those in the standard C library. On some platforms, timezones will not be parsed correctly. If the result of this function will be passed to `time` to ...
this function doesn't call `mktime`, so it could probably benefit from a rename.
end """ strptime([format], timestr) Parse a formatted time string into a `TmStruct` giving the seconds, minute, hour, date, etc. Supported formats are the same as those in the standard C library. On some platforms, timezones will not be parsed correctly. If the result of this function will be passed to `time` to ...
@@ -266,9 +266,29 @@ function strptime(fmt::AbstractString, timestr::AbstractString) throw(ArgumentError("invalid arguments")) end @static if Sys.isapple() + function callmktime(s::String)
base/libc.jl
26
Julia
0.429
suggestion
80
51
51
false
Remove `Regex` / libpcre dependency from basic `path.jl` operations
60,677
JuliaLang/julia
35,573
Julia
topolarity
johroj
Review this pull request change. Language: Julia File: base/libc.jl PR Title: Remove `Regex` / libpcre dependency from basic `path.jl` operations BEFORE CODE: end """ strptime([format], timestr) Parse a formatted time string into a `TmStruct` giving the seconds, minute, hour, date, etc. Supported formats are ...
this function doesn't call `mktime`, so it could probably benefit from a rename.
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.