Merge branch 'rinderknecht-dev' into 'dev'

Fixed a regression when removing sub-blocks

See merge request ligolang/ligo!153
This commit is contained in:
Christian Rinderknecht 2019-10-24 09:15:27 +00:00
commit 150ad6bc38
5 changed files with 21 additions and 12 deletions

View File

@ -284,7 +284,7 @@ and var_decl = {
and instruction =
Cond of conditional reg
| CaseInstr of instruction case reg
| CaseInstr of if_clause case reg
| Assign of assignment reg
| Loop of loop
| ProcCall of fun_call

View File

@ -275,7 +275,7 @@ and var_decl = {
and instruction =
Cond of conditional reg
| CaseInstr of instruction case reg
| CaseInstr of if_clause case reg
| Assign of assignment reg
| Loop of loop
| ProcCall of fun_call

View File

@ -566,7 +566,7 @@ clause_block:
ShortBlock {value; region} }
case_instr:
case(instruction) { $1 instr_to_region }
case(if_clause) { $1 if_clause_to_region }
case(rhs):
Case expr Of option(VBAR) cases(rhs) End {

View File

@ -295,7 +295,7 @@ and print_clause_block buffer = function
print_terminator buffer terminator;
print_token buffer rbrace "}"
and print_case_instr buffer (node : instruction case) =
and print_case_instr buffer (node : if_clause case) =
let {kwd_case; expr; opening;
lead_vbar; cases; closing} = node in
print_token buffer kwd_case "case";
@ -316,7 +316,7 @@ and print_case_clause_instr buffer {value; _} =
let {pattern; arrow; rhs} = value in
print_pattern buffer pattern;
print_token buffer arrow "->";
print_instruction buffer rhs
print_if_clause buffer rhs
and print_assignment buffer {value; _} =
let {lhs; assign; rhs} = value in
@ -921,7 +921,7 @@ and pp_instruction buffer ~pad:(_,pc as pad) = function
pp_conditional buffer ~pad value
| CaseInstr {value; _} ->
pp_node buffer ~pad "CaseInstr";
pp_case pp_instruction buffer ~pad value
pp_case pp_if_clause buffer ~pad value
| Assign {value; _} ->
pp_node buffer ~pad "Assign";
pp_assignment buffer ~pad value

View File

@ -708,10 +708,19 @@ and simpl_single_instruction : Raw.instruction -> (_ -> expression result) resul
let (c , loc) = r_split c in
let%bind expr = simpl_expression c.expr in
let%bind cases =
let aux (x : Raw.instruction Raw.case_clause Raw.reg) =
let%bind i = simpl_instruction x.value.rhs in
let%bind i = i None in
ok (x.value.pattern, i) in
let aux (x : Raw.if_clause Raw.case_clause Raw.reg) =
let%bind case_clause =
match x.value.rhs with
ClauseInstr i ->
simpl_single_instruction i
| ClauseBlock b ->
match b with
LongBlock {value; _} ->
simpl_block value
| ShortBlock {value; _} ->
simpl_statements @@ fst value.inside in
let%bind case_clause = case_clause None in
ok (x.value.pattern, case_clause) in
bind_list
@@ List.map aux
@@ npseq_to_list c.cases.value in