From c09adbbc2793aedcc3569681acfc42260d3b0e4b Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sat, 20 Apr 2024 23:22:19 -0700 Subject: [PATCH] generalize isBorrowedPtr and isReadonlyPtr (#16402) --- compiler/src/dmd/ob.d | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/src/dmd/ob.d b/compiler/src/dmd/ob.d index b6acef2de50a..bd985cfefbaf 100644 --- a/compiler/src/dmd/ob.d +++ b/compiler/src/dmd/ob.d @@ -1242,8 +1242,7 @@ void allocStates(ref ObState obstate) bool isBorrowedPtr(VarDeclaration v) { return v.isScope() && !v.isowner && - (!v.type.nextOf() || // could be a struct type with a pointer field - v.type.nextOf().isMutable()); + v.type.hasPointersToMutableFields(); } /****************************** @@ -1253,7 +1252,7 @@ bool isBorrowedPtr(VarDeclaration v) */ bool isReadonlyPtr(VarDeclaration v) { - return v.isScope() && !v.type.nextOf().isMutable(); + return v.isScope() && !v.type.hasPointersToMutableFields(); } /***************************************