From 54de75bdf484addb2b8ce1991e3ebb2662a451f9 Mon Sep 17 00:00:00 2001 From: Richard Van Tassel Date: Sun, 23 Feb 2025 13:31:46 -0500 Subject: [PATCH] Adds check for local variable in scope operator check --- DMCompiler/DM/Builders/DMExpressionBuilder.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DMCompiler/DM/Builders/DMExpressionBuilder.cs b/DMCompiler/DM/Builders/DMExpressionBuilder.cs index 9ef101ba4a..b6ebf7d374 100644 --- a/DMCompiler/DM/Builders/DMExpressionBuilder.cs +++ b/DMCompiler/DM/Builders/DMExpressionBuilder.cs @@ -645,8 +645,13 @@ private DMExpression BuildScopeIdentifier(DMASTScopeIdentifier scopeIdentifier, // This is the same behaviour as in BYOND, but BYOND simply raises an undefined var error. // We want to give end users an explanation at least. if (scopeMode is Normal && ctx.Proc != null) - return BadExpression(WarningCode.BadExpression, identifier.Location, - "Use of \"type::\" and \"parent_type::\" outside of a context is forbidden"); + if (ctx.Proc.GetLocalVariable(identifier.Identifier) != null) { + // actually - it's referring to a local variable named "type" or "parent_type"... just do the usual thing + expression = BuildExpression(scopeIdentifier.Expression, inferredPath); + } else { + return BadExpression(WarningCode.BadExpression, identifier.Location, + "Use of \"type::\" and \"parent_type::\" outside of a context is forbidden"); + } if (identifier.Identifier == "parent_type") { if (ctx.Type.Parent == null)