« Return to Thread: [Bug 626] New: Function definition does not overwrite variable definition

[Bug 626] New: Function definition does not overwrite variable definition

by Bugzilla from bugzilla-daemon@helma.at :: Rate this Message:

Reply to Author | View in Thread

http://helma.org/bugs/show_bug.cgi?id=626

           Summary: Function definition does not overwrite variable
                    definition
           Product: Helma
           Version: CVS trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: JavaScript Interpreter
        AssignedTo: helma-dev@...
        ReportedBy: interface@...


The following code (if defined in global context) leads to an -- at least for
me -- unexpected result by giving the first definition of the variable "foo"
precedence to the second definition of the function "foo":

var foo = function() {
   return "This is: var foo = function()";
}

function foo() {
   return "This is: function foo()";
}

Root.prototype.main_action = function() {
   res.write(foo());
}

Expected result:
This is: function foo()

Actual result:
This is: var foo = function()

I tested the same code in Firefox and it actually behaves the same. (WTF!?)

However, I don't understand this behaviour at all and consider this a bug
unless someone can explain it thoroughly. A pointer to a comprehensive source
might do the trick as well.


--
Configure bugmail: http://helma.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
_______________________________________________
Helma-dev mailing list
Helma-dev@...
http://helma.org/mailman/listinfo/helma-dev

 « Return to Thread: [Bug 626] New: Function definition does not overwrite variable definition

LightInTheBox - Buy quality products at wholesale price!