miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

Using `self` results in extra TAC code generation

Open juh9870 opened this issue 3 years ago • 3 comments

Text copied from my PR to benchmarks repo, but I was told to report this to issues in this repo too

Currently, when using self, it's getting evaluated as if it was a function, but in practice, we are ALWAYS getting unevaluated result, even when operating on funcRef, unless we are using @self, which is functionally identical but does not emit an extra TAC line for calling it. It would be great if self was always treated by compiler as if it was @self, thus not emitting any extra TAC code

Exactly the same issue applies to globals and locals, and maybe outer, but I haven't checked it

juh9870 avatar Dec 18 '22 21:12 juh9870

Well, currently it is valid to do:

self = function; print "Hi!"; end function
self

...at least at the global scope. That is, self is not a reserved word.

Should we change that? If so, how much code are we likely to break? 🤔

JoeStrout avatar Oct 31 '23 21:10 JoeStrout

Related issue: #98

JoeStrout avatar Oct 31 '23 22:10 JoeStrout

Note that locals and globals are affected as well, and they are reserved words

juh9870 avatar Nov 01 '23 00:11 juh9870