Closed Bug 5875 Opened 26 years ago Closed 26 years ago

eval anomality

Categories

(Core :: JavaScript Engine, defect, P3)

x86
Windows NT
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: norrisboyd, Assigned: rogerl)

Details

Subject: eval anomality Date: Wed, 28 Apr 1999 20:43:35 +0200 From: Martin Honnen <Martin.Honnen@sector27.de> Organization: Liberty Development Newsgroups: netscape.public.mozilla.jseng I have some strange behaviour with eval: var s = "print('typeof g = ' + typeof g);\n" + "function g () {};\n" + "print('typeof g = ' + typeof g);"; var t = "print('typeof f = ' + typeof f);\n" + "function f () {};\n" + "print('typeof f = ' + typeof f);"; function evalS () { eval(s); } evalS (); eval(t); Calling eval inside the function shows typeof g = undefined typeof g = function while the second call shows typeof f = function typeof f = function Happens with js1.4.2 but c4.51 is also effected (of course using alert instead of print). I think the second behaviour is correct as function declarations should be processed before other statements thus f should be known in both print statements but the same should hold for g. -- Martin Honnen mailto: Martin.Honnen@sector27.de http://www.sector27.de/martin.honnen
Assignee: norris → rogerl
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Fixed in jsparse.c, an anonymous function closure thingy was being constructed for this case - hiding the name until the function was encountered. I think this was to support functions in with statements, which we were already handling correctly.
Javacsript component begin retired. Moving this bug to Javascript Engine.
Status: RESOLVED → VERIFIED
verified
You need to log in before you can comment on or make changes to this bug.