Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.7
    • Component/s: Parser
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I took an initial stab at fixing this in the boo.g grammar but was getting conflicts between "not" and "not in".

      Sample code:

      a = false
      list = ["an item"]
      print "list =", list

      //I expected the below test to succeed when the list is empty,
      //and fail when the list has an item.
      //Instead it succeeds either way.

      if not a and len(list) == 0:
      print "INCORRECT SUCCESS?: not a and b"
      else:
      print "CORRECTLY FAILED: not a and b"

      //i expected the above to be like this:
      if (not a) and (len(list) == 0):
      print "(not a) and b"
      else:
      print "CORRECTLY FAILED: (not a) and b"

      //actually it is like this: (ran it through BooPrinterVisitor)
      if (not (a and (len(list) == 0))):
      print 'CORRECT SUCCESS: not (a and (b))'
      else:
      print 'FAILED: not (a and (b))'

      I tested the code with python and C# (see below) and it gave a correct failure.

      //python
      a = False
      l = ["an item"]
      if not a and len(l) == 0:
      print "incorrect success"
      else:
      print "correct failure"

      //This C# test gives a correct failure:

      using System;
      using System.Collections;

      namespace csharptest
      {
      class MainClass
      {
      public static void Main(string[] args)
      {
      bool a = false;
      ArrayList list = new ArrayList();
      list.Add("an item");

      if (! a && list.Count == 0)

      { Console.WriteLine("incorrect success: ! a && list.Count == 0"); }

      else

      { Console.WriteLine("correct failure: ! a && list.Count == 0"); }

      }
      }
      }

      And another sample by Arron Washington:

      Here's another test-case indicating that anything pass the "not"
      expression is not evaluated by the compiler.

      test =

      { print "Entered"; return false}

      if not false and test():
      print "We mistakenly arrived at this conclusion!"
      prints,
      "We mistakenly arrived at this conclusion!"

      when it should really print,

      "Entered"
      "We mistakenly arrived at this conclusion!"

        Activity

        Hide
        Rodrigo B. de Oliveira added a comment -

        patch applied. thanks Doug!

        Show
        Rodrigo B. de Oliveira added a comment - patch applied. thanks Doug!

          People

          • Assignee:
            Rodrigo B. de Oliveira
            Reporter:
            Doug H
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: