From 25dc7e031e926109628985745704fae1606c5326 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 7 Dec 2010 20:24:51 -0500 Subject: [PATCH] Ensured properties cannot be overridden with methods --- lib/util.js | 4 +++- test/test-class-extend.js | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 6f09dd2..f8049ad 100644 --- a/lib/util.js +++ b/lib/util.js @@ -228,7 +228,9 @@ exports.propCopy = function( props, dest, result_data ) } else { - // todo: attempted override of property with method + throw new Error( + "Cannot override property '" + name + "' with method" + ); } if ( data.abstractModified ) diff --git a/test/test-class-extend.js b/test/test-class-extend.js index e716c0d..7a84f75 100644 --- a/test/test-class-extend.js +++ b/test/test-class-extend.js @@ -126,3 +126,12 @@ assert.notEqual( "Subtype should contain extended members" ); + +assert.throws( function() +{ + Class.extend( OtherClass, + { + foo: function() {}, + }); +}, Error, "Cannot override property with a method" ); +