Menu

#69 another pattern match bug

closed
nobody
None
5
2007-07-09
2006-11-17
No

I have found some simple pattern match expressions that give erroneous answers. For instance: (1.1?.n1"."7.n) and ("1.A"?.n1"."7.an) both return 1 (true) but they should return 0 (false).

The error occurs when there are there are two unbounded pattern segments (no upper bound) and the lower bound on the second one is 7 or more.

Here is a test I ran on V5.1 and V5.0-000D:
-----
;testing - trailing digits in GT.M pattern match---;
w $zver

GT.M V5.1-000 Linux x86

s val="1."
f trailing=1:1:15
s val=val_(trailing#10)
w !,trailing,?5,val
f i=1:1:trailing+10 s patt=".1""-"".n1""."""_i_".n"
s expected='(i>trailing),test=val?@patt
w:test'=expected " ",i

1 1.1 7 8 9 10 11
2 1.12 7 8 9 10 11 12
3 1.123 7 8 9 10 11 12 13
4 1.1234 7 8 9 10 11 12 13 14
5 1.12345 7 8 9 10 11 12 13 14 15
6 1.123456 7 8 9 10 11 12 13 14 15 16
7 1.1234567 8 9 10 11 12 13 14 15 16 17
8 1.12345678 9 10 11 12 13 14 15 16 17 18
9 1.123456789 10 11 12 13 14 15 16 17 18 19
10 1.1234567890 11 12 13 14 15 16 17 18 19 20
11 1.12345678901 12 13 14 15 16 17 18 19 20 21
12 1.123456789012 13 14 15 16 17 18 19 20 21 22
13 1.1234567890123 14 15 16 17 18 19 20 21 22 23
14 1.12345678901234 15 16 17 18 19 20 21 22 23 24
15 1.123456789012345 16 17 18 19 20 21 22 23 24 25
-----

A workaround is put an upper bound on the repetition count for all pattern segments with no more than one exception. For instance, the intent of my first example would be met with any of the following expressions: (1.1?.9n1"."7.20n) or with (1.1?.9n1"."7.n) or (1.1?.n1"."7.20n)

Discussion

  • Narayanan Iyer

    Narayanan Iyer - 2007-07-09
    • status: open --> closed
     
  • Narayanan Iyer

    Narayanan Iyer - 2007-07-09

    Logged In: YES
    user_id=97919
    Originator: NO

    Fixed as part of C9G12-002813 in GT.M V5.2-000A.

     

Log in to post a comment.