Merge remote-tracking branch 'origin/dev' into rinderknecht-dev

This commit is contained in:
Christian Rinderknecht 2019-10-22 10:38:32 +02:00
commit fa30b7d87d
3 changed files with 15 additions and 13 deletions

View File

@ -60,17 +60,6 @@ module Errors = struct
] in
error ~data title message
let unsupported_string_catenation expr =
let title () = "string expressions" in
let message () =
Format.asprintf "string concatenation is not supported yet" in
let expr_loc = Raw.expr_to_region expr in
let data = [
("expr_loc",
fun () -> Format.asprintf "%a" Location.pp_lift @@ expr_loc)
] in
error ~data title message
let untyped_fun_param var =
let title () = "function parameter" in
let message () =
@ -446,8 +435,11 @@ let rec simpl_expression :
in
return @@ e_literal ~loc (Literal_string s')
)
| EString (Cat _) as e ->
fail @@ unsupported_string_catenation e
| EString (Cat c) ->
let (c, loc) = r_split c in
let%bind string_left = simpl_expression c.arg1 in
let%bind string_right = simpl_expression c.arg2 in
return @@ e_string_cat ~loc string_left string_right
| ELogic l -> simpl_logic_expression l
| EList l -> simpl_list_expression l
| ECase c -> (

View File

@ -0,0 +1,4 @@
(* Test that the string concatenation syntax in CameLIGO works *)
let concat_syntax (s: string) =
s ^ "test_literal"

View File

@ -203,6 +203,11 @@ let string_arithmetic () : unit result =
let%bind () = expect_fail program "slice_op" (e_string "ba") in
ok ()
let string_arithmetic_mligo () : unit result =
let%bind program = mtype_file "./contracts/string_arithmetic.mligo" in
let%bind () = expect_eq program "concat_syntax" (e_string "string_") (e_string "string_test_literal")
in ok ()
let bytes_arithmetic () : unit result =
let%bind program = type_file "./contracts/bytes_arithmetic.ligo" in
let%bind foo = e_bytes "0f00" in
@ -928,6 +933,7 @@ let main = test_suite "Integration (End to End)" [
test "arithmetic" arithmetic ;
test "bitiwse_arithmetic" bitwise_arithmetic ;
test "string_arithmetic" string_arithmetic ;
test "string_arithmetic (mligo)" string_arithmetic_mligo ;
test "bytes_arithmetic" bytes_arithmetic ;
test "set_arithmetic" set_arithmetic ;
test "unit" unit_expression ;