neo-debugger icon indicating copy to clipboard operation
neo-debugger copied to clipboard

Local variables having same name cannot be tracked

Open joeqian10 opened this issue 6 years ago • 1 comments

I have the following method in my contract:

        public static byte[] WriteVarInt(BigInteger value, byte[] Source)
        {
            if (value < 0)
            {
                return Source;
            }
            else if (value < 0xFD)
            {
                return Source.Concat(value.ToByteArray());
            }
            else if (value <= 0xFFFF) // 0xff, need to pad 1 0x00
            {
                byte[] length = new byte[] { 0xFD };
                byte[] v = PadRight(value.ToByteArray(), 2);
                return Source.Concat(length).Concat(v);
            }
            else if (value <= 0XFFFFFFFF) //0xffffff, need to pad 1 0x00 
            {
                byte[] length = new byte[] { 0xFE };
                byte[] v = PadRight(value.ToByteArray(), 4);
                return Source.Concat(length).Concat(v);
            }
            else //0x ff ff ff ff ff, need to pad 3 0x00
            {
                byte[] length = new byte[] { 0xFF };
                byte[] v = PadRight(value.ToByteArray(), 8);
                return Source.Concat(length).Concat(v);
            }
        }

The local variable "v" in three branches cannot show correct value when returned from "PadRight" method.

joeqian10 avatar Mar 05 '20 07:03 joeqian10

Thanks for reporting this. This is primarily a problem in the generated debug info, rather than the debugger, but neither has been designed to handle variable name reuse like this. I will investigate solutions for this

devhawk avatar Jun 23 '20 18:06 devhawk