From 692ba581b2e755cc615a61fb50cb32539b49f9be Mon Sep 17 00:00:00 2001 From: "David H. Brown" Date: Fri, 27 Feb 2026 17:30:44 -0500 Subject: [PATCH 1/3] Fix error message for negative factorial input While line 9 is not reached in this example, it would generate an error `found 'string + integer' expected 'string + string'`. --- asteroid/test-suites/ug-programs/prgm-031.ast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asteroid/test-suites/ug-programs/prgm-031.ast b/asteroid/test-suites/ug-programs/prgm-031.ast index 38ffb259..5eb87ebd 100644 --- a/asteroid/test-suites/ug-programs/prgm-031.ast +++ b/asteroid/test-suites/ug-programs/prgm-031.ast @@ -6,7 +6,7 @@ with n if (n is %integer) and (n > 0) do return n * factorial (n-1). with n if (n is %integer) and (n < 0) do - throw Error("factorial is not defined for "+n). + throw Error("factorial is not defined for " + tostring (n)). end io @println ("The factorial of 3 is: " + tostring (factorial 3)). From 51830f0b604bbed87687f6102372690fad788045 Mon Sep 17 00:00:00 2001 From: "David H. Brown" Date: Fri, 27 Feb 2026 17:32:20 -0500 Subject: [PATCH 2/3] Update prgm-031a.ast Same as prgm-031.ast. While line 9 is not reached in this example, it would generate an error `found 'string + integer' expected 'string + string'`. --- asteroid/test-suites/ug-programs/prgm-031a.ast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asteroid/test-suites/ug-programs/prgm-031a.ast b/asteroid/test-suites/ug-programs/prgm-031a.ast index c65ee0d0..64e1608f 100644 --- a/asteroid/test-suites/ug-programs/prgm-031a.ast +++ b/asteroid/test-suites/ug-programs/prgm-031a.ast @@ -6,7 +6,7 @@ with (n:%integer) if n > 0 do n * factorial (n-1). with (n:%integer) if n < 0 do - throw Error("factorial is not defined for "+n). + throw Error("factorial is not defined for " + tostring (n)). end io @println ("The factorial of 3 is: " + tostring (factorial 3)). From e824d83c5d5ae67c1e071787460c246c27ddc815 Mon Sep 17 00:00:00 2001 From: "David H. Brown" Date: Fri, 27 Feb 2026 17:39:11 -0500 Subject: [PATCH 3/3] prgm-003 found another missing tostring in a factorial error --- asteroid/test-suites/ug-programs/prgm-003.ast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asteroid/test-suites/ug-programs/prgm-003.ast b/asteroid/test-suites/ug-programs/prgm-003.ast index 8c25a17f..1b6e250a 100644 --- a/asteroid/test-suites/ug-programs/prgm-003.ast +++ b/asteroid/test-suites/ug-programs/prgm-003.ast @@ -9,5 +9,5 @@ with n:*pos_int do -- use first pattern return n * fact (n-1). with n:*neg_int do -- use second pattern - throw Error("undefined for "+n). + throw Error("undefined for "+ tostring (n)). end