Saving a "null" function
Misspell a function in GML editing, compile it, then delete the function from the function list, but don't actually remove the function from the GML, then save the data file, and then reload it, and then the code would cause that to come up as "null" and cause an exception during decompilation due to a null function.
@colinator27 do you have more insight on this?
I'm not sure if this is actually a bug we want to necessarily deal with, this sounds like expected behavior if you delete a function like that. However, this probably needs to get re-tested to make sure things don't completely explode in the latest version, because there's been multiple UndertaleInstruction refactors.
The new compiler does not automatically create functions with misspelled names (or possibly with correctly-spelled names). Actually creating a function() definition and then deleting both the function and script entries results in this decompiler error:
Underanalyzer.Decompiler.DecompilerException: Decompiler error during AST building: Expected push.i with function reference after fragment
---> Underanalyzer.Decompiler.DecompilerException: Expected push.i with function reference after fragment
at Underanalyzer.Decompiler.AST.IFragmentNode.Create(ASTBuilder builder, Fragment fragment)
at Underanalyzer.Decompiler.ControlFlow.Fragment.BuildAST(ASTBuilder builder, List`1 output)
at Underanalyzer.Decompiler.AST.ASTBuilder.BuildBlock(IControlFlowNode startNode)
at Underanalyzer.Decompiler.AST.IFragmentNode.Create(ASTBuilder builder, Fragment fragment)
at Underanalyzer.Decompiler.ControlFlow.Fragment.BuildAST(ASTBuilder builder, List`1 output)
at Underanalyzer.Decompiler.AST.ASTBuilder.Build()
at Underanalyzer.Decompiler.DecompileContext.DecompileAST()
--- End of inner exception stack trace ---
at Underanalyzer.Decompiler.DecompileContext.DecompileAST()
at Underanalyzer.Decompiler.DecompileContext.DecompileToAST()
at Underanalyzer.Decompiler.DecompileContext.DecompileToString()
at UndertaleModTool.UndertaleCodeEditor.<>c__DisplayClass55_1.<DecompileCode>b__1() in D:\a\UndertaleModTool\UndertaleModTool\UndertaleModTool\Editors\UndertaleCodeEditor.xaml.cs:line 739
*/
Deleting the function and script entries, as well as the actual function() call in the GlobalScript where it resides, but keeping a separate invocation of the deleted function, instead results in a game load error, which is worse:
Wow, there's a lot you can do with different configurations of deleting stuff wrong on purpose. Deleting the function() definition, which automatically and correctly deletes the Script entry, then deleting the Function entry gets a "Missing function on instruction" in decompilation of a code entry calling the function.
Overall, for normal use cases, I would say we're still doing much better already with users no longer needing to manually delete Function entries in the first place (which is what causes the rest of these problems).