From 2a004d815307f38d4ca923a8799bcfb16f638fc1 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Sun, 18 Oct 2020 22:19:27 +0000 Subject: [PATCH] fixed bug found two commits ago git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@299 4df02467-bbd4-4a76-a152-e7ce94205b78 --- src/alu.c | 29 +++++++++++++++++++++-------- src/version.h | 2 +- testing/errors/valuenotdefined1.a | 3 +++ testing/errors/valuenotdefined2.a | 3 +++ 4 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 testing/errors/valuenotdefined1.a create mode 100644 testing/errors/valuenotdefined2.a diff --git a/src/alu.c b/src/alu.c index 6b7b83d..45d0fc4 100644 --- a/src/alu.c +++ b/src/alu.c @@ -1295,8 +1295,26 @@ static boolean number_is_defined(const struct object *self) return self->u.number.ntype != NUMTYPE_UNDEFINED; } -// list/string: -// ...are always considered "defined" +// list: +// return TRUE only if completely defined +static boolean list_is_defined(const struct object *self) +{ + struct listitem *item; + + // iterate over items: if an undefined one is found, return FALSE + item = self->u.listhead->next; + while (item != self->u.listhead) { + if (!(item->u.payload.type->is_defined(&item->u.payload))) + return FALSE; // we found something undefined + + item = item->next; + } + // otherwise, list is defined + return TRUE; +} + +// string: +// ...is always considered "defined" static boolean object_return_true(const struct object *self) { return TRUE; @@ -2342,7 +2360,7 @@ struct type type_number = { }; struct type type_list = { "list", - object_return_true, // lists are always considered to be defined (even though they can hold undefined numbers...) + list_is_defined, list_differs, list_assign, list_handle_monadic_operator, @@ -2425,11 +2443,6 @@ static int parse_expression(struct expression *expression) if (!(result->type->is_defined(result))) { // then count (in all passes) ++pass.undefined_count; - // FIXME - this is a bug! lists with undefined elements are seen as "defined": - // a user macro iterating over this list will correctly choke on the undefined - // item, but the automatic iterators of "!by" and friends will just use a zero - // value, because the "undefinedness" should have been counted HERE! - // so "!by 1, 2, [three, four]" will just write "01 02 00 00" without complaints! } } // do some checks depending on int/float diff --git a/src/version.h b/src/version.h index 2b2c4cc..d79eb86 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ #define RELEASE "0.97" // update before release FIXME #define CODENAME "Zem" // update before release -#define CHANGE_DATE "24 Aug" // update before release FIXME +#define CHANGE_DATE "18 Oct" // update before release FIXME #define CHANGE_YEAR "2020" // update before release //#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" #define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME diff --git a/testing/errors/valuenotdefined1.a b/testing/errors/valuenotdefined1.a new file mode 100644 index 0000000..43e4859 --- /dev/null +++ b/testing/errors/valuenotdefined1.a @@ -0,0 +1,3 @@ +;ACME 0.97 + * = $200 + !by example diff --git a/testing/errors/valuenotdefined2.a b/testing/errors/valuenotdefined2.a new file mode 100644 index 0000000..809e15a --- /dev/null +++ b/testing/errors/valuenotdefined2.a @@ -0,0 +1,3 @@ +;ACME 0.97 + * = $200 + !by [0, 1, example]