-
-
Save nulld/71175b3b24fa56dcdb8d9fa169caa9f6 to your computer and use it in GitHub Desktop.
Why not catched?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-cpp out | |
-cp . | |
-debug | |
-main Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
interface ISomeInterface | |
{ | |
function getSomeProperty():Float; | |
} | |
class SomeClass { | |
var nullPointer:ISomeInterface; | |
public var someProperty(get, null):Float; | |
public function new() {} | |
function get_someProperty():Float { | |
return nullPointer.getSomeProperty(); | |
} | |
} | |
class Main | |
{ | |
public static function main(): Void | |
{ | |
var inst = new SomeClass(); | |
trace("Begin"); | |
trace("Begin case 1"); | |
try { | |
var unexistProperty = Reflect.getProperty(inst, "unexistProperty"); | |
trace(unexistProperty.some); | |
} | |
catch(e:Dynamic) { | |
trace(e); //Null Object Reference - works as expected | |
} | |
trace("End case 1"); | |
trace("Begin case 2"); | |
try { | |
var val = Reflect.getProperty(inst, "someProperty"); //Just crash | |
trace(val); | |
} | |
catch(e:Any) { | |
trace(e); | |
} | |
trace("End case 2"); | |
trace("Finish"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment