in reply to How to introduce a frustrating bug with a single whitespace

In a similar vein,
print (4+5)*20; # Prints 9, returns 20

Replies are listed 'Best First'.
Re^2: How to introduce a frustrating bug with a single whitespace
by radiantmatrix (Parson) on Dec 24, 2007 at 21:06 UTC

    Yes, but at least that gets caught with warnings (or -w):

    $ perl -we 'print (4+5)*20;' print (...) interpreted as function at -e line 1. Useless use of multiplication (*) in void context at -e line 1.

    The whitespace bug described in the original node is the first bug I've had in a while that:

    • wasn't caught by syntax checking (it's valid Perl)
    • wasn't griped about with strict and warnings on
    • wasn't a design error
    <radiant.matrix>
    Ramblings and references
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet
      Well, it's kind of you to say that, but given the fact that Perl 6 changed =~ to ~~, it arguably was a design error. (Though this particular failure mode is not why it was changed, but rather the failure of reversing the operator to say ~= instead. It doesn't matter if you reverse ~~.) Anyway, if you split ~~ in Perl 6 with whitespace, it'll parse, but will likely give you a "useless use of ~ in void context" warning.

      By the way, Perl 6 also fixes the "print (4+5)*20" faq...

      The whitespace bug described in the original node is the first bug I've had in a while that:
      • wasn't caught by syntax checking (it's valid Perl)
      • wasn't griped about with strict and warnings on
      • wasn't a design error

      I've got one of those, though not a whitespace bug. Just recently I was messing with a data-structure that was supposed to be an array of arrays of arrays:

      $rect_list = [ [ [0, 0], [3, 9 ] ], [ [5, 4], [3, 10] ], [ [7, 8], [9, 11] ]. [ [2, 4], [5, 15] ], [ [1, 9], [9, 13] ], ];

      First question: Can you spot the bug? Second question: Do you know what it does?