Disambiguate array tuples from lists using typing information
Motivation and Context
Currently in JSLigo the only way to make a list is by wrapping an array constructor in a pseudo-function, as in list([1, 2])
while this works well, it is really ugly and just behaves differently from what a developer coming from TypeScript would be expecting.
Description
This adds the following new features:
- Disambiguate lists from tuples using typing information
- Support for more rest operators on arrays in JSLigo
-
--feature-infer-array-as-list
, inferring arrays as list by defaults, making JSLigo closer to TypeScript
It also does the following code changes:
- Add on ast-core
E_tuple
andE_array
. - Add on ast-core and ast-unified
E_array_as_list
. - Move the nanopasses on array, tuple and lists mostly to checking.
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
Support typed-based disambiguation for lists and tuples, in JSLigo.
const a : unit = [];
const b : list<int> = [1, 2];
const c : [int, int, int] = [1, 2, 3];
Checklist:
-
If a new syntax has been introduced, put a message on slack ligo-lsp -
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 Eduardo RFS