Runtime panic on self assignment
beoran opened this issue · comments
Beoran commented
The following Tengo script panics at run time:
a := a.foo
This likely because the compiler wrongly considers a to be defined after the := . A should only be considered defined in the next statement.
E Sequeira commented
Right, this is a problem, but I'm not sure your solution would work. It would break recursive functions.
Beoran commented
For a func block, an exception can be made to the rule I propose that the variable is defined inside there.
Edit: Or, the semantics could stay the same as now, but then a.foo should return undefined in stead of panicking.
Beoran commented
Thanks for the fix!