Unknown6656 / AutoIt-Interpreter

A C# AutoIt interpreter designed to be platform-independent
GNU Affero General Public License v3.0
36 stars 10 forks source link

[BUG] `ref`-variable issues #202

Open Unknown6656 opened 2 months ago

Unknown6656 commented 2 months ago

Bug Description

when creating a new ref variable, the original variable is erased and replaced with a self-reference.

Steps to reproduce the Bug

Run the following code:

const $a = 10
dim $b = ref $a

DebugAllVarsCompact()

See:

6 row(s):
┌─────────────┬──────────────────────────┬─────────┬─────────────┬────────────┬───────────────────────────────────────────────────────────┐
│Name         │Location                  │Type     │Reference to:│   Modifiers│                                                      Value│
├─────────────┼──────────────────────────┼─────────┼─────────────┼────────────┼───────────────────────────────────────────────────────────┤
│/$a          │"0:\temp~ff316697", line 1│Reference│   $a: ref $a│CONST GLOBAL│                                                     ref $a│
│/$b          │"0:\temp~ff316697", line 1│Reference│   $a: ref $a│      GLOBAL│                                                     ref $a│
│/$cmdline    │<unknown>                 │Array    │             │CONST GLOBAL│                                                        [0]│
│/$cmdlinefull│<unknown>                 │Array    │             │CONST GLOBAL│[2, "D:\\DEV\\AutoIt-Interpreter\\bin\\autoit3.dll", "-mi"]│
│/$cmdlineraw │<unknown>                 │String   │             │CONST GLOBAL│                                                         ""│
│/$_          │<unknown>                 │Null     │             │      GLOBAL│                                                       Null│
└─────────────┴──────────────────────────┴─────────┴─────────────┴────────────┴───────────────────────────────────────────────────────────┘

Expected Behavior

6 row(s):
┌─────────────┬──────────────────────────┬─────────┬─────────────┬────────────┬───────────────────────────────────────────────────────────┐
│Name         │Location                  │Type     │Reference to:│   Modifiers│                                                      Value│
├─────────────┼──────────────────────────┼─────────┼─────────────┼────────────┼───────────────────────────────────────────────────────────┤
│/$a          │"0:\temp~ff316697", line 1│Reference│             │CONST GLOBAL│                                                         10│
│/$b          │"0:\temp~ff316697", line 1│Reference│   $a: ref $a│      GLOBAL│                                                     ref $a│
│/$cmdline    │<unknown>                 │Array    │             │CONST GLOBAL│                                                        [0]│
│/$cmdlinefull│<unknown>                 │Array    │             │CONST GLOBAL│[2, "D:\\DEV\\AutoIt-Interpreter\\bin\\autoit3.dll", "-mi"]│
│/$cmdlineraw │<unknown>                 │String   │             │CONST GLOBAL│                                                         ""│
│/$_          │<unknown>                 │Null     │             │      GLOBAL│                                                       Null│
└─────────────┴──────────────────────────┴─────────┴─────────────┴────────────┴───────────────────────────────────────────────────────────┘

Operating System Type

Windows, MacOS, Linux, Other POSIX compliant OS, Other non-POSIX compliant OS

Operating System Architecture

x86, x64, arm, arm64, Other

Operating System Descriptor

Microsoft Windows [Version 10.0.22631.3447]

AutoIt Interpreter Version

+-----------------+
|E  =+   .o       |   AUTOIT3 INTERPRETER
|. .=++    B      |     Written by Unknown6656, 2018 - 2024
|. o B..o = o     |
| . o =o.+ + .    |   https://github.com/Unknown6656/AutoIt-Interpreter/
|    .+=oSo +     |
|    o.*=. +      |   Version 0.12.2469.8671, 8a1505b24e0d4bbcb24e0bf91d5e87e7448040e3
|   o o.=oo o     |   86B5BB935E1C419C9907F8C8E82E39857C5386B9EF101B241E27394327C1E880
|  . + .oo .      |
|   o   oo        |   Use this image to compare whether two AutoIt versions are equal.
+-----------------+

Additional Information

No response