Merge branch 'feature/unsupported_ass_None' into 'dev'
Feature/unsupported_ass_none See merge request ligolang/ligo!118
This commit is contained in:
commit
6f414a8ad2
@ -406,9 +406,7 @@ and lhs =
|
||||
Path of path
|
||||
| MapPath of map_lookup reg
|
||||
|
||||
and rhs =
|
||||
Expr of expr
|
||||
| NoneExpr of c_None
|
||||
and rhs = expr
|
||||
|
||||
and loop =
|
||||
While of while_loop reg
|
||||
@ -758,9 +756,7 @@ let lhs_to_region : lhs -> Region.t = function
|
||||
Path path -> path_to_region path
|
||||
| MapPath {region; _} -> region
|
||||
|
||||
let rhs_to_region = function
|
||||
Expr e -> expr_to_region e
|
||||
| NoneExpr r -> r
|
||||
let rhs_to_region = expr_to_region
|
||||
|
||||
let selection_to_region = function
|
||||
FieldName {region; _}
|
||||
|
@ -390,9 +390,7 @@ and lhs =
|
||||
Path of path
|
||||
| MapPath of map_lookup reg
|
||||
|
||||
and rhs =
|
||||
Expr of expr
|
||||
| NoneExpr of c_None
|
||||
and rhs = expr
|
||||
|
||||
and loop =
|
||||
While of while_loop reg
|
||||
|
@ -591,7 +591,7 @@ assignment:
|
||||
in {region; value}}
|
||||
|
||||
rhs:
|
||||
expr { Expr $1 }
|
||||
expr { $1 }
|
||||
|
||||
lhs:
|
||||
path { Path $1 }
|
||||
|
@ -309,9 +309,7 @@ and print_assignment {value; _} =
|
||||
print_token assign ":=";
|
||||
print_rhs rhs
|
||||
|
||||
and print_rhs = function
|
||||
Expr e -> print_expr e
|
||||
| NoneExpr r -> print_token r "None"
|
||||
and print_rhs e = print_expr e
|
||||
|
||||
and print_lhs = function
|
||||
Path path -> print_path path
|
||||
|
@ -26,16 +26,6 @@ module Errors = struct
|
||||
] in
|
||||
error ~data title message
|
||||
|
||||
let unsupported_ass_None region =
|
||||
let title () = "assignment of None" in
|
||||
let message () =
|
||||
Format.asprintf "assignments of None are not supported yet" in
|
||||
let data = [
|
||||
("none_expr",
|
||||
fun () -> Format.asprintf "%a" Location.pp_lift @@ region)
|
||||
] in
|
||||
error ~data title message
|
||||
|
||||
let bad_bytes loc str =
|
||||
let title () = "bad bytes string" in
|
||||
let message () =
|
||||
@ -793,10 +783,7 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu
|
||||
)
|
||||
| Assign a -> (
|
||||
let (a , loc) = r_split a in
|
||||
let%bind value_expr = match a.rhs with
|
||||
| Expr e -> simpl_expression e
|
||||
| NoneExpr reg -> fail @@ unsupported_ass_None reg
|
||||
in
|
||||
let%bind value_expr = simpl_expression a.rhs in
|
||||
match a.lhs with
|
||||
| Path path -> (
|
||||
let (name , path') = simpl_path path in
|
||||
|
@ -726,7 +726,7 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a
|
||||
fail @@ not_supported_yet "assign expressions with maps are not supported yet" ae
|
||||
in
|
||||
bind_fold_list aux (typed_name.type_value , []) path in
|
||||
let%bind expr' = type_expression e expr in
|
||||
let%bind expr' = type_expression e ~tv_opt:assign_tv expr in
|
||||
let t_expr' = get_type_annotation expr' in
|
||||
let%bind () =
|
||||
trace_strong (type_error
|
||||
|
@ -4,3 +4,12 @@ type foobar is option(int)
|
||||
|
||||
const s : foobar = Some(42)
|
||||
const n : foobar = None
|
||||
|
||||
function assign (var m : int) : foobar is
|
||||
var coco : foobar := None;
|
||||
block
|
||||
{
|
||||
coco := Some(m);
|
||||
coco := None;
|
||||
}
|
||||
with coco
|
||||
|
@ -369,6 +369,10 @@ let option () : unit result =
|
||||
let expected = e_typed_none t_int in
|
||||
expect_eq_evaluate program "n" expected
|
||||
in
|
||||
let%bind () =
|
||||
let expected = e_typed_none t_int in
|
||||
expect_eq program "assign" (e_int 12) expected
|
||||
in
|
||||
ok ()
|
||||
|
||||
let moption () : unit result =
|
||||
|
Loading…
Reference in New Issue
Block a user