duktape icon indicating copy to clipboard operation
duktape copied to clipboard

An issue about the increment operator

Open YaoHouyou opened this issue 3 years ago • 1 comments

Version

2.6.0

Overview

When I calculate a-++a, duktape first calculates ++a and then a-a, and the final result is 0. However, other engines, such as v8, chakra, the result is -1. So I think it may be a bug of duktape.

Testcase

var NISLFuzzingFunc = function () {	

	var a = 1;
	return a - ++a;
};
var NISLCallingResult = NISLFuzzingFunc();

print(NISLCallingResult);

Actual Results

0

Expected Results

-1

YaoHouyou avatar Mar 03 '21 11:03 YaoHouyou

There seems to be a bug in handling the expression when 'a' is register based. When it is e.g. a global variable the evaluation order is correct.

Thanks for reporting, I'll check it out.

svaarala avatar Mar 04 '21 20:03 svaarala