From e6a174f97fc31ac68e3f1445f01da9a967c06df3 Mon Sep 17 00:00:00 2001 From: ike709 Date: Sun, 11 Feb 2024 22:40:58 -0600 Subject: [PATCH] Update an old ForcedError (#1634) Co-authored-by: ike709 Co-authored-by: wixoaGit --- DMCompiler/DM/DMProc.cs | 6 +----- DMCompiler/DM/Visitors/DMProcBuilder.cs | 10 ++++++++-- OpenDream.sln.DotSettings | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/DMCompiler/DM/DMProc.cs b/DMCompiler/DM/DMProc.cs index f24dcdd1f9..85d04ca0b8 100644 --- a/DMCompiler/DM/DMProc.cs +++ b/DMCompiler/DM/DMProc.cs @@ -367,11 +367,7 @@ public void CreateListEnumerator() { WriteOpcode(DreamProcOpcode.CreateListEnumerator); } - public void CreateFilteredListEnumerator(DreamPath filterType) { - if (!DMObjectTree.TryGetTypeId(filterType, out var filterTypeId)) { - DMCompiler.ForcedError($"Cannot filter enumeration by type {filterType}"); - } - + public void CreateFilteredListEnumerator(int filterTypeId) { WriteOpcode(DreamProcOpcode.CreateFilteredListEnumerator); WriteInt(filterTypeId); } diff --git a/DMCompiler/DM/Visitors/DMProcBuilder.cs b/DMCompiler/DM/Visitors/DMProcBuilder.cs index 60bd7a26da..59fa4828d1 100644 --- a/DMCompiler/DM/Visitors/DMProcBuilder.cs +++ b/DMCompiler/DM/Visitors/DMProcBuilder.cs @@ -618,8 +618,14 @@ public void ProcessStatementForList(DMExpression list, DMExpression outputVar, D list.EmitPushValue(_dmObject, _proc); if (implicitTypeCheck != null) { - // Create an enumerator that will do the implicit istype() for us - _proc.CreateFilteredListEnumerator(implicitTypeCheck.Value); + if (DMObjectTree.TryGetTypeId(implicitTypeCheck.Value, out var filterTypeId)) { + // Create an enumerator that will do the implicit istype() for us + _proc.CreateFilteredListEnumerator(filterTypeId); + } else { + DMCompiler.Emit(WarningCode.ItemDoesntExist, outputVar.Location, + $"Cannot filter enumeration by type {implicitTypeCheck.Value}, it does not exist"); + _proc.CreateListEnumerator(); + } } else { _proc.CreateListEnumerator(); } diff --git a/OpenDream.sln.DotSettings b/OpenDream.sln.DotSettings index 025cfa31f2..73109a6378 100644 --- a/OpenDream.sln.DotSettings +++ b/OpenDream.sln.DotSettings @@ -38,6 +38,7 @@ True True True + True True True True