diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tuplr.hpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/tuplr.hpp b/src/tuplr.hpp index c31e000..0141592 100644 --- a/src/tuplr.hpp +++ b/src/tuplr.hpp @@ -199,13 +199,11 @@ struct AST : public Object { template<typename T> T const to() const { return dynamic_cast<T const>(this); } template<typename T> T as() { T t = dynamic_cast<T>(this); - if (!t) throw Error(loc, "internal error: bad cast"); - return t; + return t ? t : throw Error(loc, "internal error: bad cast"); } template<typename T> T const as() const { T const t = dynamic_cast<T const>(this); - if (!t) throw Error(loc, "internal error: bad cast"); - return t; + return t ? t : throw Error(loc, "internal error: bad cast"); } Cursor loc; }; |