diff --git a/ChangeLog b/ChangeLog index c45b77cf8..9e4dff79a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-12-29 Shiro Kawai + + * src/read.c (read_number): Propagate numeric parser error message. + https://github.com/shirok/Gauche/issues/912 + 2024-12-25 Shiro Kawai * src/vector.c: Make uvector print routine follow writeControls diff --git a/src/read.c b/src/read.c index 2af9be9a0..90f03b902 100644 --- a/src/read.c +++ b/src/read.c @@ -1397,13 +1397,15 @@ static ScmObj read_number(ScmPort *port, ScmChar initial, int radix, flags |= SCM_NUMBER_FORMAT_STRICT_R7RS; } int default_radix = radix >= 2? radix : 10; + flags |= SCM_NUMBER_FORMAT_ERROR_MESSAGE; ScmObj num = Scm_StringToNumber(s, default_radix, flags); - if (num == SCM_FALSE) { + if (!SCM_NUMBERP(num)) { if (radix >= 2) { /* In this case, we've read #r syntax */ - Scm_ReadError(port, "bad numeric format: \"#%dr%A\"", radix, s); + Scm_ReadError(port, "bad numeric format: \"#%dr%A\": %A", + radix, s, num); } else { - Scm_ReadError(port, "bad numeric format: %S", s); + Scm_ReadError(port, "bad numeric format: %S: %A", s, num); } } return num;