Changeset 514

Show
Ignore:
Timestamp:
04/29/08 11:21:33 (8 months ago)
Author:
weyrick
Message:

don't allow redeclaration of methods in the same class. fixes #3573

Location:
trunk/pcc
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pcc/compiler/declare.scm

    r381 r514  
    356356;                         (fprint (current-error-port) "Method: " (method-decl-name p)) 
    357357                          (%check-typehints p (method-decl-decl-arglist p)) 
    358                           (php-hash-insert! methods (method-decl-name p) p)) 
     358                          (if (php-hash-contains? methods (method-decl-name p)) 
     359                              ; XXX note, this is also checked in the object runtime 
     360                              (php-error/loc node (format "Cannot redeclare ~a::~a()" name (method-decl-name p))) 
     361                              (php-hash-insert! methods (method-decl-name p) p))) 
    359362                         ((nop? p) #t) 
    360363                         (else (error 'declare-class "what's this noise doing in my class-decl?" p)))))) 
  • trunk/pcc/runtime/php-object.scm

    r510 r514  
    10411041             (overridden-method (php-hash-lookup (%php-class-methods the-class) canon-method-name))) 
    10421042         (unless (php-null? overridden-method) 
     1043 
     1044            ;; can't redeclare a method in the same class 
     1045            (when (eq? the-class (%php-method-origin-class overridden-method)) 
     1046               (php-error (format "Cannot redeclare ~a::~a()" class-name method-name))) 
     1047             
    10431048            ;; can't override a final method 
    10441049            (when (%php-method-final? overridden-method)