Repository navigation
Conversation
`BangBang.setindex!!` copies an `Array` whose element type is not an
array type, such as `Vector{Any}`, when an array value is assigned at a
scalar index, so threaded DynamicPPL tildes lose writes. Call
`setindex!` for an `Array` when the value already has its element type;
other containers keep the BangBang path.
Assisted-by: Codex <codex@openai.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #200 +/- ##
==========================================
+ Coverage 92.63% 92.69% +0.06%
==========================================
Files 17 17
Lines 2145 2149 +4
==========================================
+ Hits 1987 1992 +5
+ Misses 158 157 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
AbstractPPL.jl documentation for PR #200 is available at: |
sunxd3
reviewed
Oct 21, 2026
Assisted-by: Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
set(x, with_mutation(optic), v)returns a copy ofxwhenvis an array assigned at a scalar index andx's element type is not an array type, as withVector{Any}.BangBang.setindex!!makes the copy because its in-place check rejects that combination. DynamicPPL rebinds the container to the returned value, so under threaded evaluation each task installs its own copy and writes are lost (TuringLang/DynamicPPL.jl#1519).The setter now calls
setindex!and returnsxwhenx isa Array, every index is an integer orCartesianIndex, andv isa eltype(x). Other inputs, including views, static arrays,OffsetArrays and values that need conversion or widening, keep the BangBang path. As a result,xis mutated where it used to be copied, as already happens for concretely typed arrays, and a zero-dimensionalx[]now succeeds where it threw.This works around a false negative in BangBang's
possible, and can be removed once that is fixed upstream.Closes TuringLang/DynamicPPL.jl#1519