Handle large integer literals
commit97ef1f0d26e16c6ddc5a4559dc57f3dc78ffe1ab
authorAndy Arvanitis <andyarvanitis@gmail.com>
dateThu 16 Aug 2018, 23:40 (8 years ago)
parent56ee997
runtime/purescript.h+8
@@ -41,6 +41,14 @@ namespace purescript {
4141 boxed(const int n) : std::shared_ptr<void>(std::make_shared<int>(n)) {
4242 }
4343
44+ boxed(const long n) : std::shared_ptr<void>(std::make_shared<int>(static_cast<int>(n))) {
45+#ifndef NDEBUG
46+ if (n < std::numeric_limits<int>::min() || n > std::numeric_limits<int>::max()) {
47+ throw std::runtime_error("integer out of range");
48+ }
49+#endif // !NDEBUG
50+ }
51+
4452 boxed(const double n) : std::shared_ptr<void>(std::make_shared<double>(n)) {
4553 }
4654