1
0
Fork 0

Throwing exception on trait static member

These will be supported in future versions; this is not something that I
want to rush, nor is it something I want to hold up the first GNU release;
it is likely to be a much lesser-used feature.
perfodd
Mike Gerwitz 2014-03-11 06:37:16 -04:00
parent 316a7dd703
commit eab4dbfe4d
2 changed files with 32 additions and 0 deletions

View File

@ -152,6 +152,15 @@ function _parseMember( name, value, keywords, h )
throw Error( "Traits may not define __construct" ); throw Error( "Traits may not define __construct" );
} }
// will be supported in future versions
if ( keywords['static'] )
{
throw Error(
"Cannot define member `" + name + "'; static trait " +
"members are currently unsupported"
);
}
// apply original handler // apply original handler
h.apply( this, arguments ); h.apply( this, arguments );
} }

View File

@ -390,4 +390,27 @@ require( 'common' ).testCase(
}, },
} )().go(); } )().go();
}, },
/**
* Support for static members will be added in future versions; this is
* not something that the author wanted to rush for the first trait
* release, as static members have their own odd quirks.
*/
'Trait static members are prohibited': function()
{
var Sut = this.Sut;
// property
this.assertThrows( function()
{
Sut( { 'static private foo': 'prop' } );
} );
// method
this.assertThrows( function()
{
Sut( { 'static foo': function() {} } );
} );
},
} ); } );