Simplifier now emit CONCAT constant
This commit is contained in:
parent
0c7bfbdecd
commit
44767c4b8e
@ -488,8 +488,11 @@ let rec simpl_expression (t:Raw.expr) : expr result =
|
||||
String.(sub s 1 (length s - 2))
|
||||
in
|
||||
return @@ e_literal ~loc (Literal_string s')
|
||||
| EString (Cat _) as e ->
|
||||
fail @@ unsupported_string_catenation e
|
||||
| EString (Cat bo) ->
|
||||
let (bo , loc) = r_split bo in
|
||||
let%bind sl = simpl_expression bo.arg1 in
|
||||
let%bind sr = simpl_expression bo.arg2 in
|
||||
return @@ e_string_cat ~loc sl sr
|
||||
| ELogic l -> simpl_logic_expression l
|
||||
| EList l -> simpl_list_expression l
|
||||
| ESet s -> simpl_set_expression s
|
||||
|
@ -73,6 +73,7 @@ let e_record ?loc map : expression = location_wrap ?loc @@ E_record map
|
||||
let e_tuple ?loc lst : expression = location_wrap ?loc @@ E_tuple lst
|
||||
let e_some ?loc s : expression = location_wrap ?loc @@ E_constant ("SOME", [s])
|
||||
let e_none ?loc () : expression = location_wrap ?loc @@ E_constant ("NONE", [])
|
||||
let e_string_cat ?loc sl sr : expression = location_wrap ?loc @@ E_constant ("CONCAT" , [sl ; sr ])
|
||||
let e_map_add ?loc k v old : expression = location_wrap ?loc @@ E_constant ("MAP_ADD" , [k ; v ; old])
|
||||
let e_map ?loc lst : expression = location_wrap ?loc @@ E_map lst
|
||||
let e_set ?loc lst : expression = location_wrap ?loc @@ E_set lst
|
||||
|
@ -1 +1,3 @@
|
||||
const s : string = "toto"
|
||||
const x : string = s^"bar"
|
||||
const y : string = "foo"^x
|
||||
|
@ -262,7 +262,8 @@ let unit_expression () : unit result =
|
||||
|
||||
let string_expression () : unit result =
|
||||
let%bind program = type_file "./contracts/string.ligo" in
|
||||
expect_eq_evaluate program "s" (e_string "toto")
|
||||
let%bind _ = expect_eq_evaluate program "s" (e_string "toto") in
|
||||
expect_eq_evaluate program "y" (e_string "foototobar")
|
||||
|
||||
let include_ () : unit result =
|
||||
let%bind program = type_file "./contracts/includer.ligo" in
|
||||
|
Loading…
Reference in New Issue
Block a user