miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

Confused assignment to intrinsic functions

Open Withered-Flower-0422 opened this issue 2 years ago • 2 comments

MM:

]@pi isa funcRef
1
]pi=pi
]@pi isa funcRef
1
]@pi
FUNCTION()  // here pi is still a function
]

CL:

> @pi isa funcRef
1
> pi=pi
invalid index in SimpleVector::operator[] at C:\Users\jstrout\Documents\MiniScript-cpp\src\MiniScript/SimpleVector.h:193
Warning: assignment of unqualified local 'pi' based on nonlocal is deprecated [line 1]
> @pi isa funcRef
0
> @pi
3.141593  // here pi is a number.
>

Same situations for some other intrinsic functions like yield, time and so on. if the function is not an intrinsic one, then it behaves just fine.

Withered-Flower-0422 avatar Nov 21 '23 19:11 Withered-Flower-0422

Note that only assigning one to itself can trigger this bug. If you do pi = time, it also behaves fine.

Withered-Flower-0422 avatar Nov 21 '23 20:11 Withered-Flower-0422

Yeah, I believe there's a check in there somewhere for when the assignment is of an identifier to itself. None of this was really intended to affect the shadowing of intrinsics, though.

JoeStrout avatar Nov 21 '23 20:11 JoeStrout