From 9942ac9743363ecda03ffd3378e6b44ea2ee2adb Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 22 Dec 2011 22:48:17 -0500 Subject: [PATCH] const getters/setters are unsupported (simply omit the setter) --- lib/MemberBuilderValidator.js | 8 ++++++++ test/MemberBuilderValidator/GetterSetterTest.js | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/MemberBuilderValidator.js b/lib/MemberBuilderValidator.js index c889952..fe33c5a 100644 --- a/lib/MemberBuilderValidator.js +++ b/lib/MemberBuilderValidator.js @@ -291,6 +291,14 @@ exports.prototype.validateGetterSetter = function( ); } + // for const getters/setters, omit the setter + if ( keywords[ 'const' ] ) + { + throw TypeError( + "Cannot declare const getter/setter '" + name + "'" + ); + } + if ( prev || prev_gs ) { // perform this check first, as it will make more sense than those that diff --git a/test/MemberBuilderValidator/GetterSetterTest.js b/test/MemberBuilderValidator/GetterSetterTest.js index c5ff29c..4e37046 100644 --- a/test/MemberBuilderValidator/GetterSetterTest.js +++ b/test/MemberBuilderValidator/GetterSetterTest.js @@ -154,4 +154,15 @@ require( 'common' ).testCase( { this.quickKeywordTest( [ 'abstract' ], 'abstract' ); }, + + + /** + * As getters/setters are essentially methods, they are treated very + * similarity. They cannot be declared as const. Rather, that should be + * handled by omitting a setter. + */ + 'Cannot declare const getters/setters': function() + { + this.quickKeywordTest( [ 'const' ], 'const' ); + }, } );