We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3f8a996 commit 05dc447Copy full SHA for 05dc447
core/engine/src/bytecompiler/expression/binary.rs
@@ -4,9 +4,12 @@ use crate::{
4
};
5
use boa_ast::{
6
Expression,
7
- expression::operator::{
8
- Binary, BinaryInPrivate,
9
- binary::{ArithmeticOp, BinaryOp, BitwiseOp, LogicalOp, RelationalOp},
+ expression::{
+ literal::LiteralKind,
+ operator::{
10
+ Binary, BinaryInPrivate,
11
+ binary::{ArithmeticOp, BinaryOp, BitwiseOp, LogicalOp, RelationalOp},
12
+ },
13
},
14
15
@@ -15,7 +18,14 @@ impl ByteCompiler<'_> {
18
match binary.op() {
16
19
BinaryOp::Arithmetic(op) => {
17
20
self.compile_expr_operand(binary.lhs(), |self_, lhs| {
- self_.compile_binary_arithmetic(op, binary.rhs(), dst, lhs);
21
+ if op == ArithmeticOp::Sub
22
+ && let Expression::Literal(literal) = binary.rhs().flatten()
23
+ && let LiteralKind::Int(1) = literal.kind()
24
+ {
25
+ self_.bytecode.emit_dec(dst.variable(), lhs);
26
+ } else {
27
+ self_.compile_binary_arithmetic(op, binary.rhs(), dst, lhs);
28
+ }
29
});
30
}
31
BinaryOp::Bitwise(op) => {
0 commit comments