diff --git a/Underanalyzer/Decompiler/AST/Nodes/VariableCallNode.cs b/Underanalyzer/Decompiler/AST/Nodes/VariableCallNode.cs index e0da287..6b8d4f7 100644 --- a/Underanalyzer/Decompiler/AST/Nodes/VariableCallNode.cs +++ b/Underanalyzer/Decompiler/AST/Nodes/VariableCallNode.cs @@ -75,7 +75,7 @@ public void Print(ASTPrinter printer) { // We have a "builtin" type on our variable, so use what's on the stack instead. // Have to also check if we *need* "self." or not, if that's what Instance happens to be. - if (Instance is not InstanceTypeNode instType2 || instType2.InstanceType != IGMInstruction.InstanceType.Self || + if (Instance is not InstanceTypeNode instType2 || instType2.InstanceType != IGMInstruction.InstanceType.Self || // TODO: for later investigation: does Builtin also need to be checked in 2024 versions? printer.LocalVariableNames.Contains(variable.Variable.Name.Content) || printer.TopFragmentContext.NamedArguments.Contains(variable.Variable.Name.Content)) { diff --git a/Underanalyzer/Decompiler/AST/Nodes/VariableNode.cs b/Underanalyzer/Decompiler/AST/Nodes/VariableNode.cs index 8bd13b4..4cee4de 100644 --- a/Underanalyzer/Decompiler/AST/Nodes/VariableNode.cs +++ b/Underanalyzer/Decompiler/AST/Nodes/VariableNode.cs @@ -244,6 +244,7 @@ public void Print(ASTPrinter printer) switch (value) { case (int)InstanceType.Self: + case (int)InstanceType.Builtin: if (printer.LocalVariableNames.Contains(Variable.Name.Content) || printer.TopFragmentContext.NamedArguments.Contains(Variable.Name.Content)) { diff --git a/UnderanalyzerTest/DecompileContext.DecompileToString.cs b/UnderanalyzerTest/DecompileContext.DecompileToString.cs index c3e4e68..8e8cc30 100644 --- a/UnderanalyzerTest/DecompileContext.DecompileToString.cs +++ b/UnderanalyzerTest/DecompileContext.DecompileToString.cs @@ -1820,4 +1820,48 @@ function default_args_locals(arg0 = 123) """ ); } + + [Fact] + public void TestArgumentsSelf() + { + TestUtil.VerifyDecompileResult( + """ + :[0] + b [4] + + > gml_Script_default_arg_color (locals=0, args=1) + :[1] + push.v arg.argument0 + pushbltn.v builtin.undefined + cmp.v.v EQ + bf [3] + + :[2] + push.i 1 + pop.v.i arg.argument0 + + :[3] + pushi.e 123 + pop.v.i builtin.arg0 + exit.i + + :[4] + push.i [function]gml_Script_default_arg_color + conv.i.v + pushi.e -1 + conv.i.v + call.i method 2 + dup.v 0 + pushi.e -1 + pop.v.v [stacktop]self.default_arg_color + popz.v + """, + """ + function default_arg_color(arg0 = 1) + { + self.arg0 = 123; + } + """ + ); + } }