Browse Source

one more fix in logical expressions and "~"

Vladislav Folts 11 years ago
parent
commit
05cee39dc4
3 changed files with 5 additions and 1 deletions
  1. 3 1
      src/context.js
  2. 1 0
      test/expected/logical.js
  3. 1 0
      test/input/logical.ob

+ 3 - 1
src/context.js

@@ -923,8 +923,10 @@ exports.Term = ChainedContext.extend({
     endParse: function(){this.parent().handleTerm(this.__expression);},
     handleExpression: function(e){
         promoteExpressionType(this, this.__expression, e);
-        if (this.__logicalNot)
+        if (this.__logicalNot){
             e = op.not(e);
+            this.__logicalNot = false;
+        }
         if (this.__operator)
             e = this.__expression ? this.__operator(this.__expression, e)
                                   : this.__operator(e);

+ 1 - 0
test/expected/logical.js

@@ -8,4 +8,5 @@ b1 = b1 && b2 || !b1;
 b1 = b2 && !b1;
 b1 = b2 || b1;
 b1 = b2 || !!(b1 && b2);
+b1 = !b1 && !b2;
 }();

+ 1 - 0
test/input/logical.ob

@@ -12,4 +12,5 @@ BEGIN
     b1 := b2 & ~b1;
     b1 := b2 OR ~~b1;
     b1 := b2 OR ~(~(b1 & b2));
+    b1 := ~b1 & ~b2;
 END m.