Fix std::randomize internal error on static member of different class (#7498) (#7499)

Fixes #7498.
This commit is contained in:
hjsanjana
2026-04-26 06:24:40 -04:00
committed by GitHub
parent 2875ec8655
commit 982b9ee219
4 changed files with 107 additions and 0 deletions
+5
View File
@@ -2824,6 +2824,11 @@ class CaptureVisitor final : public VNVisitor {
&& varRefp->varp()->lifetime().isStatic())
return CaptureMode::CAP_NO;
if (callerIsClass && varIsFieldOfCaller) return CaptureMode::CAP_THIS;
// Static member of a different class: V3Width replaces AstMemberSel with a bare
// AstVarRef (classOrPackagep set). Capture current value as a function argument.
if (callerIsClass && varClassp && !varIsFieldOfCaller
&& varRefp->varp()->lifetime().isStatic())
return CaptureMode::CAP_VALUE;
UASSERT_OBJ(!callerIsClass, varRefp, "Invalid reference?");
return CaptureMode::CAP_VALUE;
}