From c569029b1d9ca16e35cd6d9692d3f6a4131ce668 Mon Sep 17 00:00:00 2001 From: Player701 Date: Thu, 15 Nov 2018 23:39:13 +0300 Subject: [PATCH] - Readonly pointer casting now works in ZScript. --- src/scripting/backend/codegen.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 8576bcae18..015bae2d0d 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -4691,14 +4691,7 @@ FxExpression *FxDynamicCast::Resolve(FCompileContext& ctx) { CHECKRESOLVED(); SAFE_RESOLVE(expr, ctx); - bool constflag = expr->ValueType->isPointer() && expr->ValueType->toPointer()->IsConst; - if (constflag) - { - // readonly pointers are normally only used for class defaults which lack type information to be cast properly, so we have to error out here. - ScriptPosition.Message(MSG_ERROR, "Cannot cast a readonly pointer"); - delete this; - return nullptr; - } + bool constflag = expr->ValueType->isPointer() && expr->ValueType->toPointer()->IsConst; expr = new FxTypeCast(expr, NewPointer(RUNTIME_CLASS(DObject), constflag), true, true); expr = expr->Resolve(ctx); if (expr == nullptr)