1
0
Fork 0

const getters/setters are unsupported (simply omit the setter)

perfodd
Mike Gerwitz 2011-12-22 22:48:17 -05:00
parent 4ada84e3b7
commit 9942ac9743
2 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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' );
},
} );