I missed a glaring logic error in JavascriptGenerator in my previous review:

JavascriptGenerator#1419:

The global table is a red herring.  It started out as an attempted solution to 
this problem, but it was an incorrect one.  I'm sorry that it is still there, 
because I think it led you down the garden path...

We _can't_ remove globals from possibleInstance if the classdesc is not 
complete.  If it's not complete, we don't know that there might not be instance 
vars that alias globals.  If the classdesc _is_ complete, we don't need 
possibleInstance, because we know the actual instance from the classdesc.

In fact, the compiler's knowledge of globals is really useless for the purposes 
of computing if we need with(this) or not.  The only use for globals would be 
to emit a warning when there are free references that the compiler cannot 
identify as a global.

The real logic of this section should be:

  if classdesc complete OR if incomplete but all free references are in 
classdesc:
    rewrite all free references that are in classdesc
  otherwise:
    emit a warning and use with(this)

As a bonus:

  if classdesc complete and there are free references _not_ in classdesc:
    compare those free references to known globals and emit a warning for any 
that cannot be identified

Sorry that I missed this.

Reply via email to