Fix: JsLigo attributes not propagated in the pipeline
Motivation and Context
There was a bug reported on #ligo slack that attributes are not propagated in the pipeline, More info in the issue:
Fixes #1634 (closed)
Description
Fixes the bug in CST, Parser
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
For a contract like
type action_t =
// @layout:comb
| ["A"]
| ["B", int]
| ["C", [int, int]];
type storage_t =
// @layout comb
{
x: int,
y: int,
z: int
};
type return_t = [list<operation>, storage_t];
const main = (action: action_t, _: storage_t): return_t =>
[
list([]),
match(action, {
A: () => ({ x: 10, y: 10, z: 10 }),
B: (_) => ({ x: 20, y: 20, z: 20 }),
C: (_) => ({ x: 20, y: 20, z: 20 })
})
];
Before
$ ligo.60 compile contract y.jsligo
{ parameter (or (or (unit %a) (int %b)) (pair %c int int)) ;
storage (pair (pair (int %x) (int %y)) (int %z)) ;
code { CAR ;
IF_LEFT
{ IF_LEFT
{ DROP ; PUSH int 10 ; PUSH int 10 ; PUSH int 10 }
{ DROP ; PUSH int 20 ; PUSH int 20 ; PUSH int 20 } }
{ DROP ; PUSH int 20 ; PUSH int 20 ; PUSH int 20 } ;
PAIR ;
PAIR ;
NIL operation ;
PAIR } }
After
$ ligo compile contract y.jsligo
{ parameter (or (unit %a) (or (int %b) (pair %c int int))) ;
storage (pair (int %x) (int %y) (int %z)) ;
code { CAR ;
IF_LEFT
{ DROP ; PUSH int 10 ; PUSH int 10 ; PUSH int 10 }
{ IF_LEFT
{ DROP ; PUSH int 20 ; PUSH int 20 ; PUSH int 20 }
{ DROP ; PUSH int 20 ; PUSH int 20 ; PUSH int 20 } } ;
PAIR 3 ;
NIL operation ;
PAIR } }
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