Skip to content

Commit

Permalink
Fixed an issue with the boolean negation operator
Browse files Browse the repository at this point in the history
Fixed an issue where the boolean negation operator would modify the original boolean, instead of returning a new, negated one.
  • Loading branch information
schwalbe-t authored Jan 25, 2023
1 parent c993665 commit 2f5220e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions currant.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,7 @@ class CurrantNegateBooleanNode extends CurrantNode {
let value = super.childValue(0);
if(typeof value.get() !== "boolean")
throw new Error(`failed to negate value - "${this.children[0].src}" is not a boolean`);
value.value[0] = !value.value[0];
return value;
return value.type.fromValue(!value.get());
}

}
Expand Down
3 changes: 1 addition & 2 deletions currant/nodes/booleanLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class CurrantNegateBooleanNode extends CurrantNode {
let value = super.childValue(0);
if(typeof value.get() !== "boolean")
throw new Error(`failed to negate value - "${this.children[0].src}" is not a boolean`);
value.value[0] = !value.value[0];
return value;
return value.type.fromValue(!value.get());
}

}
Expand Down

0 comments on commit 2f5220e

Please sign in to comment.