Fixed transpilation of "True", "False" and "Unit".
Motivation and Context
The CST-to-CST transpilation from PascaLIGO to JsLIGO was incorrect on values for the predefined data constructors True
, False
and Unit
. With this MR we transpile
const _ = case x of [True -> 0 | False -> 1]
const _ = case y of [A -> True | B -> False]
into
const _ = match(x, { True: () => 0, False: () => 1 });
const _ = match(y, { A: () => true, B: () => false });
The boolean values in patterns remain unchanged (True
and False
) because of technical difficulties in the pipeline. We argue that matching on those values is bad style, as a conditional is best. Moreover, we do not have deep pattern matching is JsLIGO, so conditionals should be the obvious choice.
Description
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
Fixed transpilation from PascaLIGO to JsLIGO of predefined data constructors "True", "False" and "Unit" as values (patterns remain unchanged).
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 Christian Rinderknecht