Skip to content

ref.duplicate

← ref dialect

Create an independent handle to the same managed payload, preserving its type and null state. Duplicating ref adds an owner that must be released or transferred independently. Duplicating ptr preserves its borrowed mode and any protection needed through its final use. The source remains valid; live source and result lifetimes are independent.

Operation contract

Property Value
Semantic phase executable
Traits UniqueIdentity, StorageRelation, ObservableEffect
Interfaces ValueDuplication

Signature

Kind Name Type Cardinality Description
Operand sources any variadic —
Result duplicates any variadic —

Verification constraints

  • ClosedValueTuple(sources)
  • ClosedValueTuple(duplicates)
  • VariadicValuesMatch(duplicates, sources)

Examples

%copy = ref.duplicate %owner : ref<@Object>
%saved = ref.duplicate %pointer : ptr<@Object>