diff --git a/phpunit/code/bigfloat-unsupported-mod.php b/phpunit/code/bigfloat-unsupported-mod.php new file mode 100644 index 00000000..fac352a5 --- /dev/null +++ b/phpunit/code/bigfloat-unsupported-mod.php @@ -0,0 +1,9 @@ +exec("Operator '%' is not supported for Big* numeric types", 'bigfloat-unsupported-mod.php'); + } + + public function testDecimalBitAnd() + { + $this->exec("Operator '&' is not supported for Big* numeric types", 'decimal-unsupported-bitand.php'); + } + + public function testBigFloatShiftLeft() + { + $this->exec("Operator '<<' is not supported for Big* numeric types", 'bigfloat-unsupported-shift.php'); + } + + public function testDecimalBitOr() + { + $this->exec("Operator '|' is not supported for Big* numeric types", 'decimal-unsupported-bitor.php'); + } +} diff --git a/src/Php/Parser/BinaryOpTrait.php b/src/Php/Parser/BinaryOpTrait.php index 0ff4147c..759051d9 100644 --- a/src/Php/Parser/BinaryOpTrait.php +++ b/src/Php/Parser/BinaryOpTrait.php @@ -106,6 +106,12 @@ trait BinaryOpTrait } } + // Any Big*-typed operand reaching here means no Big* block handled the operator + $bigTypes = [self::TYPE_BIGFLOAT, self::TYPE_DECIMAL, self::TYPE_BIGINT]; + if (in_array($leftType, $bigTypes, true) || in_array($rightType, $bigTypes, true)) { + $this->fatalError($left, "Operator '{$op}' is not supported for Big* numeric types"); + } + // Only promote between native types (Int ↔ Float). When one side is // php::Var, let the Variant operator handle type coercion so that // run-time PHP type-juggling rules are followed correctly.