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
parent
316a7dd703
commit
eab4dbfe4d
|
@ -152,6 +152,15 @@ function _parseMember( name, value, keywords, h )
|
|||
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
|
||||
h.apply( this, arguments );
|
||||
}
|
||||
|
|
|
@ -390,4 +390,27 @@ require( 'common' ).testCase(
|
|||
},
|
||||
} )().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() {} } );
|
||||
} );
|
||||
},
|
||||
} );
|
||||
|
|
Loading…
Reference in New Issue