Fix invalid setfield! fallback in MOIOptimizationNLPCache setproperty!#1236
Merged
ChrisRackauckas merged 1 commit intoJun 26, 2026
Merged
Conversation
`MOIOptimizationNLPCache` is an immutable struct whose `setproperty!` delegates mutation to the (mutable) evaluator and its `ReInitCache`. The final fallback called `setfield!(cache, name, x)` on the immutable cache itself, which can never succeed and which JET flagged as a guaranteed error (`setfield!: immutable struct ... cannot be changed`). Replace the dead fallback with an explicit, informative `ArgumentError`. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RtJAi7bALH5XkakjS6Yb6j
SebastianM-C
approved these changes
Jun 25, 2026
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.
Summary
MOIOptimizationNLPCacheis an immutable struct whose customsetproperty!delegates mutation to the (mutable)evaluatorand itsReInitCache. The final fallback calledsetfield!(cache, name, x)on the immutable cache itself — which can never succeed and which JET (report_package) flags as a guaranteed error:This replaces the dead fallback with an explicit, informative
ArgumentError. Functionally equivalent (both error), but it makes the intent clear and removes the JET finding.Testing
Verified with
JET.test_package(OptimizationMOI; target_defined_modules = true)locally on Julia 1.12.6: thesetproperty!/setfield!finding is gone.Relationship to #1235
The OptimizationMOI QA (Aqua + JET) job is red on
masterfor three independent reasons. #1235 fixes the two Aqua findings (allowed-piracy declaration + missingReverseDiffcompat) and thecache.verboseJET finding; this PR fixes the remainingsetproperty!JET finding. I confirmed locally that with both PRs applied,JET.test_packagepasses cleanly (0 errors) and Aqua passes 11/11 — i.e. the two together turn the QA job green. Neither is individually sufficient.This PR is a draft and should be ignored until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RtJAi7bALH5XkakjS6Yb6j