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)