Compiler Bug in 'with'

View: New views
1 Messages — Rating Filter:   Alert me  

Compiler Bug in 'with'

by Mark Winterhalder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

there seems to be a bug when a property gets deleted inside 'with'.
(Of course 'with' shouldn't be used in the first place, but I was
helping somebody on IRC who had inherited the code.)

Here's the description of the 'phenomenon', observed with Mtasc that
came with FD3 beta 2:


>>>
// both swf's contain this exact same class
// one compiled in Flash, one compiled in FlashDevelop
// Flash gives undefined, FlashDevelop gives 10 in a trace.

class Test
{
        public function Test()
        {
                var o = new Object;
                o.i = 5;
                with(o) {
                          delete i;
                          i = 10;
                }
                trace(o.i);
        }
}
<<<

Flasm shows the difference between the two compilers:

// mtasc
      with
        push "i"
        getVariable  // <-- shouldn't be here!
        push 1, "delete"
        callFunction
        pop
        push "i", 10
        setVariable
      end

// flash
      with
        push "i"
        delete2
        pop
        push "i", 10
        setVariable
      end


Also, I'm curious -- why does Mtasc call delete as a function?

Mark

--
MTASC : no more coffee break while compiling