git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Handle large integer literals
97ef1f0Andy Arvanitis
runtime/purescript.h+8
@@ -41,6 +41,14 @@ namespace purescript {
41 boxed(const int n) : std::shared_ptr<void>(std::make_shared<int>(n)) {
41 boxed(const int n) : std::shared_ptr<void>(std::make_shared<int>(n)) {
42 }
42 }
43
43
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+
44 boxed(const double n) : std::shared_ptr<void>(std::make_shared<double>(n)) {
52 boxed(const double n) : std::shared_ptr<void>(std::make_shared<double>(n)) {
45 }
53 }
46
54