mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 02:40:49 +00:00
LibJS/Bytecode: Perform ToNumeric on accumulator before postfix inc/dec
This ensures we get the expected behavior of code like:
let a = []
let b = a++
(Where b should be 0, not [], because JavaScript.)
This commit is contained in:
@@ -1966,6 +1966,7 @@ Bytecode::CodeGenerationErrorOr<void> UpdateExpression::generate_bytecode(Byteco
|
||||
Optional<Bytecode::Register> previous_value_for_postfix_reg;
|
||||
if (!m_prefixed) {
|
||||
previous_value_for_postfix_reg = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::ToNumeric>();
|
||||
generator.emit<Bytecode::Op::Store>(*previous_value_for_postfix_reg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user