ItsDeltin / Overwatch-Script-To-Workshop

Converts scripts to Overwatch workshops.
208 stars 26 forks source link

Bug: Cannot use parameters in overrided methods #427

Closed badcodecat closed 1 year ago

badcodecat commented 1 year ago

When overriding a virtual method if you use a parameter an exception is thrown. Example code to reproduce:

class Parent
{
    public virtual Number test(Number test_parameter)
    {
        return 0;
    }
}

class Child : Parent
{
    public override Number test(Number test_parameter)
    {
        return test_parameter;
    }
}

rule: "Test"
{
    Parent foo = new Child();
    foo.test(1);
}

Output (error):

An exception was thrown while translating to workshop.
System.Exception: The variable test_parameter is not assigned to an index.
   at Deltin.Deltinteger.Parse.VarIndexAssigner.Get(IVariable variable) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Variables/Workshop/VarIndexAssigner.cs:line 52
   at Deltin.Deltinteger.Parse.VariableInstance.ToWorkshop(ActionSet actionSet) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Variables/User/VarInstance.cs:line 58
   at Deltin.Deltinteger.Parse.CallVariableAction.Parse(ActionSet actionSet) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Variables/Semantics/CallVariableAction.cs:line 23
   at Deltin.Deltinteger.Parse.ReturnAction.Translate(ActionSet actionSet) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Statement.cs:line 73
   at Deltin.Deltinteger.Parse.BlockAction.Translate(ActionSet actionSet) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Block.cs:line 36
   at Deltin.Deltinteger.Parse.Functions.Builder.Virtual.AbstractVirtualContentBuilder`1.Build() in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Functions/Builder/Virtual/AbstractVirtualContentBuilder.cs:line 63
   at Deltin.Deltinteger.Parse.Functions.Builder.User.UserFunctionController.Build(ActionSet actionSet) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Functions/Builder/User/UserFunctionController.cs:line 103
   at Deltin.Deltinteger.Parse.Functions.Builder.WorkshopFunctionBuilder.BuildInline(ICallInfo call) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Functions/Builder/Builder.cs:line 110
   at Deltin.Deltinteger.Parse.ExpressionTree.ParseTree(ActionSet actionSet, Boolean expectingValue) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/ExpressionTree.cs:line 211
   at Deltin.Deltinteger.Parse.ExpressionTree.Translate(ActionSet actionSet) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/ExpressionTree.cs:line 171
   at Deltin.Deltinteger.Parse.BlockAction.Translate(ActionSet actionSet) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Block.cs:line 36
   at Deltin.Deltinteger.Parse.DeltinScript.ToWorkshop(Func`2 addRules) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Translate.cs:line 260
   at Deltin.Deltinteger.Parse.DeltinScript..ctor(TranslateSettings translateSettings) in /home/kate/Programming/github/Overwatch-Script-To-Workshop/Deltinteger/Deltinteger/Parse/Translate.cs:line 57