]> granicus.if.org Git - php/commitdiff
Fixed bug #29104 (Function declaration in method doesn't work)
authorDmitry Stogov <dmitry@php.net>
Wed, 27 Apr 2005 13:30:53 +0000 (13:30 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 27 Apr 2005 13:30:53 +0000 (13:30 +0000)
Zend/tests/bug29104.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/bug29104.phpt b/Zend/tests/bug29104.phpt
new file mode 100644 (file)
index 0000000..c7afbee
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #29104 Function declaration in method doesn't work 
+--FILE--
+<?php
+class A
+{ 
+  function g() 
+  { 
+    echo "function g - begin\n";
+    
+    function f() 
+    { 
+      echo "function f\n";
+    } 
+
+    echo "function g - end\n";
+  }
+}
+
+$a = new A;
+$a->g();
+f();
+?>
+--EXPECT--
+function g - begin
+function g - end
+function f
index d3ee2c3f0234d08e96e9272ef0ae26da9de618e1..de876333d0efedde3d6a3ab13b87e438f3660872 100644 (file)
@@ -1039,7 +1039,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
        op_array.fn_flags = fn_flags;
        op_array.pass_rest_by_reference = 0;
 
-       op_array.scope = CG(active_class_entry);
+       op_array.scope = is_method?CG(active_class_entry):NULL;
        op_array.prototype = NULL;
 
        op_array.line_start = zend_get_compiled_lineno(TSRMLS_C);