[JsLIGO]: Add increment & decrement operators (`++` & `--`)
Motivation and Context
The prefix & postfix (increment & decrement) operators (++
&& --
) were missing in JsLIGO.
These operators are useful in writing for loops
Description
TODOs
-
Add grammar & CST nodes -
Add nodes in Ast_unified -
Nanopass -
Compiler -
Decompiler
-
-
Add expect tests for compilation & running tests -
Add Unit tests for nanopass (compiler & decompiler) -
Update docs on website
Component
-
compiler -
website -
webide -
vscode-plugin -
debugger
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to not work as expected) -
Performance improvement (non-breaking change that improves performance) -
None (change with no changelog)
Changelog
This MR adds to increment & decrement operators (++
&& --
) to JsLIGO.
For example
const testIncDec = (() => {
let inc = 0;
// Prefix increment operator
assert(++inc == 1);
// Postfix increment operator
assert(inc++ == 1);
assert(inc == 2);
let dec = 10;
// Prefix decrement operator
assert(--dec == 9);
// Postfix decrement operator
assert(dec-- == 9);
assert(dec == 8);
})();
Result
$ ligo run test x.jsligo
Everything at the top-level was executed.
- testIncDec exited with value ().
Checklist:
-
Changes follow the existing coding style (use dune @fmt
to check). -
Tests for the changes have been added (for bug fixes / feature). -
Documentation has been updated. -
Changelog description has been added (if appropriate). -
Start titles under ## Changelog
section with #### (if appropriate). -
There is no image or uploaded file in changelog -
Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by Melwyn Saldanha