JoeStrout/miniscript

Using `self` results in extra TAC code generation

Opened this issue · 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

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? 🤔

Related issue: #98

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