Fix attribute access on captured composite constants #2024
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 334 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.348
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2024"
general
weight: 0.35
efegokdemir
What problem are you trying to solve?
Captured vector, quaternion, transformation, and struct values were returned unchanged when accessing an attribute in a kernel, so component/field access could produce incorrect results or type errors.
Closes #2023
What does this change?
Keep the existing early handling for scalar/native constants, let captured ctypes composite values use the existing vector/quaternion/transformation extraction paths, and resolve captured struct fields as compile-time constants.
Existing pull requests
Validation
test_captured_constant_attributes, covering captured vector components, transformation quaternion components, scalar/composite fields on a directly captured module-levelStructInstance,wp.static(), and an@wp.funcpath. The unsupported closure-capturedStructInstancecase was removed after validation showed Warp does not accept struct instances as closure constants.python3 -m py_compile warp/_src/codegen.py warp/tests/test_compile_consts.py; pre-commit passed including Ruff, Ruff format, generated-file/version checks, and typo checks;git diff --checkpassed.test_compile_consts.py; this macOS checkout has no builtwarp/bin/libwarp.dylib, so import/collection stops during native library initialization. The original collection blocker fromwp.constant(StructInstance)and the invalid closure-captured struct test are removed.Checklist
mainand contains one commit, unless a maintainer agreed to keep the change as multiple commits.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
Fixed attribute access for captured vector, quaternion, transformation, and struct values in compiled kernels. Components and fields can now be read from captured values, including scalar struct fields and vector and transformation components.
* Struct field access also works through
wp.staticand an@wp.funcpath.<!-- end of auto-generated comment: release notes by coderabbit.ai -->