Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update an old ForcedError #1634

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions DMCompiler/DM/DMProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,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);
}
Expand Down
10 changes: 8 additions & 2 deletions DMCompiler/DM/Visitors/DMProcBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
_proc.JumpIfFalse(afterDefaultValueCheck);

//Set default
try {

Check warning on line 47 in DMCompiler/DM/Visitors/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build

'CompileErrorException' is obsolete: 'This is not a desirable way for the compiler to emit an error. Use CompileAbortException or ForceError() if it needs to be fatal, or an DMCompiler.Emit() otherwise.'

Check warning on line 47 in DMCompiler/DM/Visitors/DMProcBuilder.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'CompileErrorException' is obsolete: 'This is not a desirable way for the compiler to emit an error. Use CompileAbortException or ForceError() if it needs to be fatal, or an DMCompiler.Emit() otherwise.'
DMExpression.Emit(_dmObject, _proc, parameter.Value, parameter.ObjectType);
} catch (CompileErrorException e) {
DMCompiler.Emit(e.Error);
Expand Down Expand Up @@ -556,8 +556,14 @@

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();
}
Expand Down
1 change: 1 addition & 0 deletions OpenDream.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=ispath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=issaved/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=isturf/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=istype/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=keybind/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=lerp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=lerping/@EntryIndexedValue">True</s:Boolean>
Expand Down
Loading