From 45618198140b67d992b5136a6d2268eeccca5fcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Thu, 2 Jun 2022 12:01:31 +0200
Subject: [PATCH] Remove division by boolean values

As observed by Emmanuel dividing by boolean make little sense.
This is thus removed from the language.

Binary operator / and affectation operator /= are changed
---
 .../utils/AffectationRegisterForN.cpp         |   4 -
 .../utils/AffectationRegisterForR.cpp         |   4 -
 .../utils/AffectationRegisterForZ.cpp         |   4 -
 .../utils/BinaryOperatorRegisterForB.cpp      |  10 --
 .../utils/BinaryOperatorRegisterForB.hpp      |   1 -
 .../utils/BinaryOperatorRegisterForN.cpp      |  14 ++-
 .../utils/BinaryOperatorRegisterForN.hpp      |   1 +
 .../utils/BinaryOperatorRegisterForR.cpp      |  24 ++++-
 .../utils/BinaryOperatorRegisterForR.hpp      |   1 +
 .../utils/BinaryOperatorRegisterForZ.cpp      |  19 +++-
 .../utils/BinaryOperatorRegisterForZ.hpp      |   1 +
 ...ASTNodeBinaryOperatorExpressionBuilder.cpp | 100 ++++++++++++------
 tests/test_AffectationProcessor.cpp           |  78 +++++++++++++-
 ...t_BinaryExpressionProcessor_arithmetic.cpp |   4 -
 14 files changed, 200 insertions(+), 65 deletions(-)

diff --git a/src/language/utils/AffectationRegisterForN.cpp b/src/language/utils/AffectationRegisterForN.cpp
index e7d54008f..64f93ad0f 100644
--- a/src/language/utils/AffectationRegisterForN.cpp
+++ b/src/language/utils/AffectationRegisterForN.cpp
@@ -95,10 +95,6 @@ AffectationRegisterForN::_register_divideeq_op()
 
   auto N = ASTNodeDataType::build<ASTNodeDataType::unsigned_int_t>();
 
-  repository.addAffectation<
-    language::divideeq_op>(N, ASTNodeDataType::build<ASTNodeDataType::bool_t>(),
-                           std::make_shared<AffectationProcessorBuilder<language::divideeq_op, uint64_t, bool>>());
-
   repository.addAffectation<
     language::divideeq_op>(N, ASTNodeDataType::build<ASTNodeDataType::unsigned_int_t>(),
                            std::make_shared<AffectationProcessorBuilder<language::divideeq_op, uint64_t, uint64_t>>());
diff --git a/src/language/utils/AffectationRegisterForR.cpp b/src/language/utils/AffectationRegisterForR.cpp
index ae7c63c40..7959b35b3 100644
--- a/src/language/utils/AffectationRegisterForR.cpp
+++ b/src/language/utils/AffectationRegisterForR.cpp
@@ -113,10 +113,6 @@ AffectationRegisterForR::_register_divideeq_op()
 
   auto R = ASTNodeDataType::build<ASTNodeDataType::double_t>();
 
-  repository.addAffectation<
-    language::divideeq_op>(R, ASTNodeDataType::build<ASTNodeDataType::bool_t>(),
-                           std::make_shared<AffectationProcessorBuilder<language::divideeq_op, double, bool>>());
-
   repository.addAffectation<
     language::divideeq_op>(R, ASTNodeDataType::build<ASTNodeDataType::unsigned_int_t>(),
                            std::make_shared<AffectationProcessorBuilder<language::divideeq_op, double, uint64_t>>());
diff --git a/src/language/utils/AffectationRegisterForZ.cpp b/src/language/utils/AffectationRegisterForZ.cpp
index 9937a0edb..09c493e71 100644
--- a/src/language/utils/AffectationRegisterForZ.cpp
+++ b/src/language/utils/AffectationRegisterForZ.cpp
@@ -95,10 +95,6 @@ AffectationRegisterForZ::_register_divideeq_op()
 
   auto Z = ASTNodeDataType::build<ASTNodeDataType::int_t>();
 
-  repository.addAffectation<
-    language::divideeq_op>(Z, ASTNodeDataType::build<ASTNodeDataType::bool_t>(),
-                           std::make_shared<AffectationProcessorBuilder<language::divideeq_op, int64_t, bool>>());
-
   repository.addAffectation<
     language::divideeq_op>(Z, ASTNodeDataType::build<ASTNodeDataType::unsigned_int_t>(),
                            std::make_shared<AffectationProcessorBuilder<language::divideeq_op, int64_t, uint64_t>>());
diff --git a/src/language/utils/BinaryOperatorRegisterForB.cpp b/src/language/utils/BinaryOperatorRegisterForB.cpp
index 7145ebab7..ceae7c6be 100644
--- a/src/language/utils/BinaryOperatorRegisterForB.cpp
+++ b/src/language/utils/BinaryOperatorRegisterForB.cpp
@@ -66,15 +66,6 @@ BinaryOperatorRegisterForB::_register_multiply()
     std::make_shared<BinaryOperatorProcessorBuilder<language::multiply_op, uint64_t, bool, bool>>());
 }
 
-void
-BinaryOperatorRegisterForB::_register_divide()
-{
-  OperatorRepository& repository = OperatorRepository::instance();
-
-  repository.addBinaryOperator<language::divide_op>(
-    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, uint64_t, bool, bool>>());
-}
-
 BinaryOperatorRegisterForB::BinaryOperatorRegisterForB()
 {
   this->_register_ostream();
@@ -83,5 +74,4 @@ BinaryOperatorRegisterForB::BinaryOperatorRegisterForB()
   this->_register_plus();
   this->_register_minus();
   this->_register_multiply();
-  this->_register_divide();
 }
diff --git a/src/language/utils/BinaryOperatorRegisterForB.hpp b/src/language/utils/BinaryOperatorRegisterForB.hpp
index 545b49c50..c2bdeff3d 100644
--- a/src/language/utils/BinaryOperatorRegisterForB.hpp
+++ b/src/language/utils/BinaryOperatorRegisterForB.hpp
@@ -10,7 +10,6 @@ class BinaryOperatorRegisterForB
   void _register_plus();
   void _register_minus();
   void _register_multiply();
-  void _register_divide();
 
  public:
   BinaryOperatorRegisterForB();
diff --git a/src/language/utils/BinaryOperatorRegisterForN.cpp b/src/language/utils/BinaryOperatorRegisterForN.cpp
index 9d77d842e..246832b3a 100644
--- a/src/language/utils/BinaryOperatorRegisterForN.cpp
+++ b/src/language/utils/BinaryOperatorRegisterForN.cpp
@@ -42,6 +42,18 @@ BinaryOperatorRegisterForN::_register_arithmetic()
     std::make_shared<BinaryOperatorProcessorBuilder<OperatorT, uint64_t, uint64_t, uint64_t>>());
 }
 
+void
+BinaryOperatorRegisterForN::_register_divide()
+{
+  OperatorRepository& repository = OperatorRepository::instance();
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, uint64_t, bool, uint64_t>>());
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, uint64_t, uint64_t, uint64_t>>());
+}
+
 void
 BinaryOperatorRegisterForN::_register_minus()
 {
@@ -63,5 +75,5 @@ BinaryOperatorRegisterForN::BinaryOperatorRegisterForN()
   this->_register_arithmetic<language::plus_op>();
   this->_register_minus();
   this->_register_arithmetic<language::multiply_op>();
-  this->_register_arithmetic<language::divide_op>();
+  this->_register_divide();
 }
diff --git a/src/language/utils/BinaryOperatorRegisterForN.hpp b/src/language/utils/BinaryOperatorRegisterForN.hpp
index 997b6be7a..7598529db 100644
--- a/src/language/utils/BinaryOperatorRegisterForN.hpp
+++ b/src/language/utils/BinaryOperatorRegisterForN.hpp
@@ -7,6 +7,7 @@ class BinaryOperatorRegisterForN
   void _register_ostream();
   template <typename OperatorT>
   void _register_arithmetic();
+  void _register_divide();
   void _register_comparisons();
   void _register_minus();
 
diff --git a/src/language/utils/BinaryOperatorRegisterForR.cpp b/src/language/utils/BinaryOperatorRegisterForR.cpp
index 8f5d51275..4ae9c936f 100644
--- a/src/language/utils/BinaryOperatorRegisterForR.cpp
+++ b/src/language/utils/BinaryOperatorRegisterForR.cpp
@@ -58,6 +58,28 @@ BinaryOperatorRegisterForR::_register_arithmetic()
     std::make_shared<BinaryOperatorProcessorBuilder<OperatorT, double, double, double>>());
 }
 
+void
+BinaryOperatorRegisterForR::_register_divide()
+{
+  OperatorRepository& repository = OperatorRepository::instance();
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, double, bool, double>>());
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, double, double, uint64_t>>());
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, double, uint64_t, double_t>>());
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, double, double, int64_t>>());
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, double, int64_t, double_t>>());
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, double, double, double>>());
+}
+
 BinaryOperatorRegisterForR::BinaryOperatorRegisterForR()
 {
   this->_register_ostream();
@@ -65,5 +87,5 @@ BinaryOperatorRegisterForR::BinaryOperatorRegisterForR()
   this->_register_arithmetic<language::plus_op>();
   this->_register_arithmetic<language::minus_op>();
   this->_register_arithmetic<language::multiply_op>();
-  this->_register_arithmetic<language::divide_op>();
+  this->_register_divide();
 }
diff --git a/src/language/utils/BinaryOperatorRegisterForR.hpp b/src/language/utils/BinaryOperatorRegisterForR.hpp
index c14fa410f..342ecc682 100644
--- a/src/language/utils/BinaryOperatorRegisterForR.hpp
+++ b/src/language/utils/BinaryOperatorRegisterForR.hpp
@@ -7,6 +7,7 @@ class BinaryOperatorRegisterForR
   void _register_ostream();
   template <typename OperatorT>
   void _register_arithmetic();
+  void _register_divide();
   void _register_comparisons();
 
  public:
diff --git a/src/language/utils/BinaryOperatorRegisterForZ.cpp b/src/language/utils/BinaryOperatorRegisterForZ.cpp
index 8174f3f49..13d7cb8fa 100644
--- a/src/language/utils/BinaryOperatorRegisterForZ.cpp
+++ b/src/language/utils/BinaryOperatorRegisterForZ.cpp
@@ -50,6 +50,23 @@ BinaryOperatorRegisterForZ::_register_arithmetic()
     std::make_shared<BinaryOperatorProcessorBuilder<OperatorT, int64_t, int64_t, int64_t>>());
 }
 
+void
+BinaryOperatorRegisterForZ::_register_divide()
+{
+  OperatorRepository& repository = OperatorRepository::instance();
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, int64_t, bool, int64_t>>());
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, int64_t, int64_t, uint64_t>>());
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, int64_t, uint64_t, int64_t>>());
+
+  repository.addBinaryOperator<language::divide_op>(
+    std::make_shared<BinaryOperatorProcessorBuilder<language::divide_op, int64_t, int64_t, int64_t>>());
+}
+
 BinaryOperatorRegisterForZ::BinaryOperatorRegisterForZ()
 {
   this->_register_ostream();
@@ -57,5 +74,5 @@ BinaryOperatorRegisterForZ::BinaryOperatorRegisterForZ()
   this->_register_arithmetic<language::plus_op>();
   this->_register_arithmetic<language::minus_op>();
   this->_register_arithmetic<language::multiply_op>();
-  this->_register_arithmetic<language::divide_op>();
+  this->_register_divide();
 }
diff --git a/src/language/utils/BinaryOperatorRegisterForZ.hpp b/src/language/utils/BinaryOperatorRegisterForZ.hpp
index cb734843d..ac8e93166 100644
--- a/src/language/utils/BinaryOperatorRegisterForZ.hpp
+++ b/src/language/utils/BinaryOperatorRegisterForZ.hpp
@@ -7,6 +7,7 @@ class BinaryOperatorRegisterForZ
   void _register_ostream();
   template <typename OperatorT>
   void _register_arithmetic();
+  void _register_divide();
   void _register_comparisons();
 
  public:
diff --git a/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp b/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp
index 48a4af3d2..8a59ce4fb 100644
--- a/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp
+++ b/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp
@@ -214,29 +214,6 @@ let x : R^3, x = (3.2,6,1.2);
 
   SECTION("divide")
   {
-    SECTION("B")
-    {
-      std::string_view data = R"(
-let b : B;
-b/true;
-false/b/true;
-)";
-
-      std::string_view result = R"(
-(root:ASTNodeListProcessor)
- +-(language::divide_op:BinaryExpressionProcessor<language::divide_op, unsigned long, bool, bool>)
- |   +-(language::name:b:NameProcessor)
- |   `-(language::true_kw:ValueProcessor)
- `-(language::divide_op:BinaryExpressionProcessor<language::divide_op, unsigned long, unsigned long, bool>)
-     +-(language::divide_op:BinaryExpressionProcessor<language::divide_op, unsigned long, bool, bool>)
-     |   +-(language::false_kw:ValueProcessor)
-     |   `-(language::name:b:NameProcessor)
-     `-(language::true_kw:ValueProcessor)
-)";
-
-      CHECK_AST(data, result);
-    }
-
     SECTION("N")
     {
       std::string_view data = R"(
@@ -279,18 +256,16 @@ a/3/a;
     SECTION("R")
     {
       std::string_view data = R"(
-2.3/1.2/2/false;
+2.3/1.2/2;
 )";
 
       std::string_view result = R"(
 (root:ASTNodeListProcessor)
- `-(language::divide_op:BinaryExpressionProcessor<language::divide_op, double, double, bool>)
-     +-(language::divide_op:BinaryExpressionProcessor<language::divide_op, double, double, long>)
-     |   +-(language::divide_op:BinaryExpressionProcessor<language::divide_op, double, double, double>)
-     |   |   +-(language::real:2.3:ValueProcessor)
-     |   |   `-(language::real:1.2:ValueProcessor)
-     |   `-(language::integer:2:ValueProcessor)
-     `-(language::false_kw:ValueProcessor)
+ `-(language::divide_op:BinaryExpressionProcessor<language::divide_op, double, double, long>)
+     +-(language::divide_op:BinaryExpressionProcessor<language::divide_op, double, double, double>)
+     |   +-(language::real:2.3:ValueProcessor)
+     |   `-(language::real:1.2:ValueProcessor)
+     `-(language::integer:2:ValueProcessor)
 )";
 
       CHECK_AST(data, result);
@@ -1860,6 +1835,69 @@ n >> m;
       REQUIRE_THROWS_WITH(ASTNodeBinaryOperatorExpressionBuilder{*ast}, "unexpected error: undefined binary operator");
     }
 
+    SECTION("Invalid divide by bool operators")
+    {
+      SECTION("B lhs")
+      {
+        auto ast = std::make_unique<ASTNode>();
+        ast->set_type<language::divide_op>();
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>();
+        ast->children[1]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>();
+
+        REQUIRE_THROWS_WITH(ASTNodeBinaryOperatorExpressionBuilder{*ast}, "undefined binary operator type: B / B");
+      }
+
+      SECTION("N lhs")
+      {
+        auto ast = std::make_unique<ASTNode>();
+        ast->set_type<language::divide_op>();
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::unsigned_int_t>();
+        ast->children[1]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>();
+
+        REQUIRE_THROWS_WITH(ASTNodeBinaryOperatorExpressionBuilder{*ast}, "undefined binary operator type: N / B");
+      }
+
+      SECTION("Z lhs")
+      {
+        auto ast = std::make_unique<ASTNode>();
+        ast->set_type<language::divide_op>();
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::int_t>();
+        ast->children[1]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>();
+
+        REQUIRE_THROWS_WITH(ASTNodeBinaryOperatorExpressionBuilder{*ast}, "undefined binary operator type: Z / B");
+      }
+
+      SECTION("R lhs")
+      {
+        auto ast = std::make_unique<ASTNode>();
+        ast->set_type<language::divide_op>();
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::double_t>();
+        ast->children[1]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>();
+
+        REQUIRE_THROWS_WITH(ASTNodeBinaryOperatorExpressionBuilder{*ast}, "undefined binary operator type: R / B");
+      }
+
+      SECTION("string lhs")
+      {
+        auto ast = std::make_unique<ASTNode>();
+        ast->set_type<language::divide_op>();
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children.emplace_back(std::make_unique<ASTNode>());
+        ast->children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::string_t>();
+        ast->children[1]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>();
+
+        REQUIRE_THROWS_WITH(ASTNodeBinaryOperatorExpressionBuilder{*ast}, "undefined binary operator type: string / B");
+      }
+    }
+
     SECTION("Invalid string binary operators")
     {
       SECTION("lhs bad multiply")
diff --git a/tests/test_AffectationProcessor.cpp b/tests/test_AffectationProcessor.cpp
index 42c0514f9..dc3244556 100644
--- a/tests/test_AffectationProcessor.cpp
+++ b/tests/test_AffectationProcessor.cpp
@@ -314,28 +314,25 @@ TEST_CASE("AffectationProcessor", "[language]")
     {
       CHECK_AFFECTATION_RESULT("let n : N, n = 4; n /= 2;", "n", 2ul);
       CHECK_AFFECTATION_RESULT("let m : N, m = 2; let n : N, n = 6; n /= m;", "n", 3ul);
-      CHECK_AFFECTATION_RESULT("let n : N, n = 1; n /= true;", "n", 1ul);
     }
 
     SECTION("Z")
     {
       CHECK_AFFECTATION_RESULT("let z : Z, z = 7; z /= -3;", "z", -2l);
       CHECK_AFFECTATION_RESULT("let m : N, m = 3; let z : Z, z = 6; z /= m;", "z", 2l);
-      CHECK_AFFECTATION_RESULT("let z : Z, z = 6; z /= true;", "z", 6l);
     }
 
     SECTION("R")
     {
       CHECK_AFFECTATION_RESULT("let r : R, r = 1.1; r /= 2;", "r", (1.1 / 2l));
       CHECK_AFFECTATION_RESULT("let m : N, m = 2; let r : R, r = 1.3; r /= m;", "r", (1.3 / 2ul));
-      CHECK_AFFECTATION_RESULT("let r : R, r = 1.1; r /= true;", "r", (1.1 / true));
       CHECK_AFFECTATION_RESULT("let r : R, r = 2; r /= 1.1;", "r", (2. / 1.1));
     }
   }
 
   SECTION("errors")
   {
-    SECTION("invalid implicit conversions")
+    SECTION("invalid affectations")
     {
       SECTION("-> B")
       {
@@ -343,6 +340,30 @@ TEST_CASE("AffectationProcessor", "[language]")
         CHECK_AFFECTATION_THROWS_WITH("let b : B; b = 1;", "undefined affectation type: B = Z");
         CHECK_AFFECTATION_THROWS_WITH("let b : B; b = 2.3;", "undefined affectation type: B = R");
         CHECK_AFFECTATION_THROWS_WITH("let b : B; b = \"foo\";", "undefined affectation type: B = string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b += b;", "undefined affectation type: B += B");
+        CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 1; let b : B; b += n;", "undefined affectation type: B += N");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b += 1;", "undefined affectation type: B += Z");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b += 1.2;", "undefined affectation type: B += R");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b += \"foo\";", "undefined affectation type: B += string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b -= b;", "undefined affectation type: B -= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 1; let b : B; b -= n;", "undefined affectation type: B -= N");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b -= 1;", "undefined affectation type: B -= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b -= 1.2;", "undefined affectation type: B -= R");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b -= \"foo\";", "undefined affectation type: B -= string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b *= b;", "undefined affectation type: B *= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 1; let b : B; b *= n;", "undefined affectation type: B *= N");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b *= 1;", "undefined affectation type: B *= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b *= 1.2;", "undefined affectation type: B *= R");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b *= \"foo\";", "undefined affectation type: B *= string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b /= b;", "undefined affectation type: B /= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 1; let b : B; b /= n;", "undefined affectation type: B /= N");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b /= 1;", "undefined affectation type: B /= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b /= 1.2;", "undefined affectation type: B /= R");
+        CHECK_AFFECTATION_THROWS_WITH("let b : B; b /= \"foo\";", "undefined affectation type: B /= string");
       }
 
       SECTION("-> N")
@@ -359,6 +380,7 @@ TEST_CASE("AffectationProcessor", "[language]")
         CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 2; n *= 2.51;", "undefined affectation type: N *= R");
         CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 2; n *= \"foobar\";", "undefined affectation type: N *= string");
 
+        CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 2; n /= true;", "undefined affectation type: N /= B");
         CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 2; n /= 2.51;", "undefined affectation type: N /= R");
         CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 2; n /= \"foo\";", "undefined affectation type: N /= string");
       }
@@ -377,6 +399,7 @@ TEST_CASE("AffectationProcessor", "[language]")
         CHECK_AFFECTATION_THROWS_WITH("let z : Z, z = 2; z *= -2.51;", "undefined affectation type: Z *= R");
         CHECK_AFFECTATION_THROWS_WITH("let z : Z, z = 2; z *= \"foobar\";", "undefined affectation type: Z *= string");
 
+        CHECK_AFFECTATION_THROWS_WITH("let z : Z, z = 4; z /= true;", "undefined affectation type: Z /= B");
         CHECK_AFFECTATION_THROWS_WITH("let z : Z, z = 4; z /= -2.;", "undefined affectation type: Z /= R");
         CHECK_AFFECTATION_THROWS_WITH("let z : Z, z = 2; z /= \"foo\";", "undefined affectation type: Z /= string");
       }
@@ -388,6 +411,8 @@ TEST_CASE("AffectationProcessor", "[language]")
         CHECK_AFFECTATION_THROWS_WITH("let x : R, x = 2.1; x -= \"bar\";", "undefined affectation type: R -= string");
         CHECK_AFFECTATION_THROWS_WITH("let x : R, x = 1.2; x *= \"foobar\";",
                                       "undefined affectation type: R *= string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let x : R, x =-2.3; x /= true;", "undefined affectation type: R /= B");
         CHECK_AFFECTATION_THROWS_WITH("let x : R, x =-2.3; x /= \"foo\";", "undefined affectation type: R /= string");
       }
 
@@ -433,6 +458,27 @@ TEST_CASE("AffectationProcessor", "[language]")
                                       "incompatible dimensions in affectation: expecting 3, but provided 2");
         CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = (1,2,3,4);",
                                       "incompatible dimensions in affectation: expecting 3, but provided 4");
+
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1, x = 0; x /= true;", "undefined affectation type: R^1 /= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n:N, n=1; let x : R^1, x = 0; x /= n;",
+                                      "undefined affectation type: R^1 /= N");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1, x = 0; x /= 3;", "undefined affectation type: R^1 /= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1, x = 0; x /= 3.2;", "undefined affectation type: R^1 /= R");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1, x = 0; x /= \"foo\";", "undefined affectation type: R^1 /= string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = 0; x /= true;", "undefined affectation type: R^2 /= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n:N, n=1; let x : R^2, x = 0; x /= n;",
+                                      "undefined affectation type: R^2 /= N");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = 0; x /= 3;", "undefined affectation type: R^2 /= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = 0; x /= 3.2;", "undefined affectation type: R^2 /= R");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = 0; x /= \"foo\";", "undefined affectation type: R^2 /= string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = 0; x /= true;", "undefined affectation type: R^3 /= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n:N, n=1; let x : R^3, x = 0; x /= n;",
+                                      "undefined affectation type: R^3 /= N");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = 0; x /= 3;", "undefined affectation type: R^3 /= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = 0; x /= 3.2;", "undefined affectation type: R^3 /= R");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = 0; x /= \"foo\";", "undefined affectation type: R^3 /= string");
       }
 
       SECTION("-> R^n (affectation of components is forbidden)")
@@ -596,6 +642,30 @@ TEST_CASE("AffectationProcessor", "[language]")
                                       "incompatible dimensions in affectation: expecting 9, but provided 8");
         CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = (1,2,3,4,5,6,7,8,9,10);",
                                       "incompatible dimensions in affectation: expecting 9, but provided 10");
+
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1, x = 0; x /= true;", "undefined affectation type: R^1x1 /= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n:N, n=1; let x : R^1x1, x = 0; x /= n;",
+                                      "undefined affectation type: R^1x1 /= N");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1, x = 0; x /= 3;", "undefined affectation type: R^1x1 /= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1, x = 0; x /= 3.2;", "undefined affectation type: R^1x1 /= R");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1, x = 0; x /= \"foo\";",
+                                      "undefined affectation type: R^1x1 /= string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = 0; x /= true;", "undefined affectation type: R^2x2 /= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n:N, n=1; let x : R^2x2, x = 0; x /= n;",
+                                      "undefined affectation type: R^2x2 /= N");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = 0; x /= 3;", "undefined affectation type: R^2x2 /= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = 0; x /= 3.2;", "undefined affectation type: R^2x2 /= R");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = 0; x /= \"foo\";",
+                                      "undefined affectation type: R^2x2 /= string");
+
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = 0; x /= true;", "undefined affectation type: R^3x3 /= B");
+        CHECK_AFFECTATION_THROWS_WITH("let n:N, n=1; let x : R^3x3, x = 0; x /= n;",
+                                      "undefined affectation type: R^3x3 /= N");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = 0; x /= 3;", "undefined affectation type: R^3x3 /= Z");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = 0; x /= 3.2;", "undefined affectation type: R^3x3 /= R");
+        CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = 0; x /= \"foo\";",
+                                      "undefined affectation type: R^3x3 /= string");
       }
     }
   }
diff --git a/tests/test_BinaryExpressionProcessor_arithmetic.cpp b/tests/test_BinaryExpressionProcessor_arithmetic.cpp
index 10699f3c0..83869150f 100644
--- a/tests/test_BinaryExpressionProcessor_arithmetic.cpp
+++ b/tests/test_BinaryExpressionProcessor_arithmetic.cpp
@@ -272,7 +272,6 @@ TEST_CASE("BinaryExpressionProcessor arithmetic", "[language]")
   {
     SECTION("lhs is B")
     {
-      CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = false / true;)", "n", 0ul);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = 2; n = true / n;)", "n", 0ul);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let z:Z, z = false / 1;)", "z", 0l);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let r:R, r = true / 1.2;)", "r", (true / 1.2));
@@ -280,7 +279,6 @@ TEST_CASE("BinaryExpressionProcessor arithmetic", "[language]")
 
     SECTION("lhs is N")
     {
-      CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = 3; n = n / true;)", "n", 3ul);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = 4; let m:N, m = 2; n = n / m;)", "n", 2ul);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = 5; n = n / 4;)", "n", 1ul);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = 3; let x:R, x = n / 2.3;)", "x", double{3ul / 2.3});
@@ -288,7 +286,6 @@ TEST_CASE("BinaryExpressionProcessor arithmetic", "[language]")
 
     SECTION("lhs is Z")
     {
-      CHECK_BINARY_EXPRESSION_RESULT(R"(let z:Z, z = -1 / true;)", "z", -1l);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = 4; let z:Z, z = 3 / n;)", "z", 0l);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let z:Z, z = 7 / 2;)", "z", 3l);
       CHECK_BINARY_EXPRESSION_RESULT(R"(let x:R, x = 4 / 2.4;)", "x", double{4l / 2.4});
@@ -296,7 +293,6 @@ TEST_CASE("BinaryExpressionProcessor arithmetic", "[language]")
 
     SECTION("lhs is R")
     {
-      CHECK_BINARY_EXPRESSION_RESULT(R"(let r:R, r = -1.2 / true;)", "r", (-1.2 / true));
       CHECK_BINARY_EXPRESSION_RESULT(R"(let n:N, n = 2; let r:R, r = -1.2 / n;)", "r", (-1.2 / uint64_t{2}));
       CHECK_BINARY_EXPRESSION_RESULT(R"(let r:R, r = -1.2 / 11;)", "r", (-1.2 / 11));
       CHECK_BINARY_EXPRESSION_RESULT(R"(let r:R, r = -1.2 / 2.3;)", "r", (-1.2 / 2.3));
-- 
GitLab