#882 NOSTRING condition with .nil

v4.0
closed
nobody
5
2012-08-14
2010-02-11
oorexxpert
No

I am getting a NOSTRING condition raised on the statement DO WHILE NEXT <> .nil. I tried to create a test case but it wouldn't fail. There must be something else going on or other conditions in the while expression that I am am unaware of. The snippet of code that fails is:

strings = arg(2,"ARRAY");
next = strings~first;
do while next <> .nil; <---- fails with NOSTRING condition
current = next;
next = strings~next(current);
values[current]
end;

The condition object at the time of failure is:

CONDITION is NOSTRING
INSTRUCTION is SIGNAL
PROPAGATED is 0
DESCRIPTION is The NIL object
ADDITIONAL is The NIL object

If I reverse the ".nil" and "next", it works fine.

When I tried my test case, it worked either way. If there is something I need to do to get my test case to fail, let me know.

Discussion

  • Rick McGuire
    Rick McGuire
    2010-02-11

    Assuming that the value in NEXT is a string value, than raising a NOSTRING condition is the correct action. You have asked that this condition be raised whenever it is necessary that a non-string object be converted into a string. When you are performing a comparison with a string object on the left-hand side of the compare, the comparison object needs to be converted to a string value. To suppress the nostring condition, change the compare to place the .nil on the left-hand side of the expression.

     


Anonymous


Cancel   Add attachments