diff --git a/src/Expr.cc b/src/Expr.cc index 1e01d7bc39..27594c23e2 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -3757,8 +3757,7 @@ IntrusivePtr TableCoerceExpr::Fold(Val* v) const if ( tv->Size() > 0 ) RuntimeErrorWithCallStack("coercion of non-empty table/set"); - return make_intrusive(GetType(), - IntrusivePtr{NewRef{}, tv->Attrs()}); + return make_intrusive(GetType(), tv->GetAttrs()); } VectorCoerceExpr::VectorCoerceExpr(IntrusivePtr arg_op, diff --git a/src/Val.h b/src/Val.h index c00dc07afc..83c36b400c 100644 --- a/src/Val.h +++ b/src/Val.h @@ -915,8 +915,13 @@ public: void SetAttrs(IntrusivePtr attrs); Attr* FindAttr(attr_tag t) const; + + [[deprecated("Remove in v4.1. Use GetAttrs().")]] Attributes* Attrs() { return attrs.get(); } + const IntrusivePtr& GetAttrs() const + { return attrs; } + // Returns the size of the table. int Size() const; int RecursiveSize() const; diff --git a/src/option.bif b/src/option.bif index 27fd236fc2..9f3f359148 100644 --- a/src/option.bif +++ b/src/option.bif @@ -104,7 +104,7 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool // Just coerce an empty/unspecified table to the right type. auto tv = make_intrusive( cast_intrusive(i->GetType()), - IntrusivePtr{NewRef{}, i->GetVal()->AsTableVal()->Attrs()}); + i->GetVal()->AsTableVal()->GetAttrs()); auto rval = call_option_handlers_and_set_value(ID, i, std::move(tv), location); return val_mgr->Bool(rval); }