From 8195fbed4a8067362656d38e56fec3c4eb3deef1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 24 Jan 2019 22:48:37 -0800 Subject: lib: revise wording of integer range errors. * arith.c (c_unum): Fix misleading error message, and instead specify the range that was violated. * lib.c (c_num): Similar change: don't refer to a 'cnum range' which means nothing to the user. --- lib.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 925bf638..26806b41 100644 --- a/lib.c +++ b/lib.c @@ -3099,20 +3099,21 @@ val num(cnum n) return bignum(n); } -cnum c_num(val num) +cnum c_num(val n) { - switch (type(num)) { + switch (type(n)) { case CHR: case NUM: - return coerce(cnum, num) >> TAG_SHIFT; + return coerce(cnum, n) >> TAG_SHIFT; case BGNUM: - if (in_int_ptr_range(num)) { + if (in_int_ptr_range(n)) { int_ptr_t out; - mp_get_intptr(mp(num), &out); + mp_get_intptr(mp(n), &out); return out; } - uw_throwf(error_s, lit("~s is out of cnum range"), num, nao); + uw_throwf(error_s, lit("~s is out of allowed range [~s, ~s]"), + n, num(INT_PTR_MIN), num(INT_PTR_MAX), nao); default: - type_mismatch(lit("~s is not an integer"), num, nao); + type_mismatch(lit("~s is not an integer"), n, nao); } } -- cgit v1.2.3