Quote:
Originally Posted by BAILOPAN
Neutering __nullable__
For such an important piece of future type system sanity, this one was a pretty bad leak. It was undocumented but that didn't stop people from creating alternate nullable systems that violated its intended semantics. __nullable__ will still allow using new with custom constructors, but it won't allow comparing to null.
|
How would this change the syntax of the constructors in an example like
https://github.com/VoiDeD/sourcemod-...tional-helpers ? There might be some lingering violations of a null comparison in entity.inc but keeping __nullable__ on the CBaseEntity methodmap seems to prevent an instantiation of a child object like
CBasePlayer player = new CBasePlayer( client );
edit: in case this is a bug and not just another syntactic miss on my part,
if I modify
https://github.com/alliedmodders/sou...e-methodmap.sp to
PHP Code:
native void printnum(int num);
methodmap Crab __nullable__
{
public Crab() {
return view_as<Crab>(2);
}
};
methodmap King < Crab
{
public King() {
return view_as<King>(new Crab());
}
};
methodmap Layer3 < King
{
public Layer3() {
return view_as<Layer3>(new King());
}
}
public main()
{
Crab egg = new Crab();
printnum(_:egg);
King baby = new King();
printnum(_:baby);
Layer3 stuff = new Layer3();
printnum(_:stuff);
}
it produces:
//// test-nullable.sp
//
// test-nullable.sp(29) : error 171: cannot use 'new' with non-object-like methodmap 'King'
// test-nullable.sp(29) : warning 213: tag mismatch
// test-nullable.sp(32) : error 171: cannot use 'new' with non-object-like methodmap 'Layer3'
// test-nullable.sp(32) : warning 213: tag mismatch
//
__________________