Closed Bug 1142392 Opened 9 years ago Closed 9 years ago

javascript nested function "is not defined"

Categories

(Firefox :: Untriaged, defect)

36 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 585536

People

(Reporter: demidov, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0
Build ID: 20150305021524

Steps to reproduce:

Look at
http://www.ibiblio.org/e-notes/Splines/garden/test_ff.htm

function webGLStart() {
...
function apples(tx,ty,tz){
   apple(.05, 0);
}
function apple(age, tyb){
...
    patch_rot();

 function patch_rot(){
 ...
 }
} // end  apple()
} // end  webGLStart()



Actual results:

ReferenceError: patch_rot is not defined


Expected results:

the script works fine in Chrome and IE
Your sample is

function webGLStart() {
...
function apples(tx,ty,tz){
   apple(.05, 0);
}
function apple(age, tyb){
  ...
  for (...;...;...) {
    patch_rot();

    function patch_rot(){
      ...
    }
  } // end for

} // end  apple()
} // end  webGLStart()


So function patch_rot() is not a function declaration.
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions#Function_constructor_vs._function_declaration_vs._function_expression
Dupe Bug 1071877 ?
sorry,
occasionally I put function constructor  "patch_rot(" into a "for" cycle,
but I was misled by Chrome and IE.
The original testcase is down, I'm guessing it didn't use the strict mode, so it's a dupe of 585536.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.