From e60144665d431b0b9f0f35f5cdd3992e2cd0feaa Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 26 Oct 2022 16:00:07 +0700 Subject: [PATCH 01/41] feat(all): `return` keyword and `Return` statement in AST --- deps/cryptoutils/src | 2 +- src/base/Accept.ml | 5 +++-- src/base/Callgraph.ml | 4 ++-- src/base/Cashflow.ml | 15 +++++++++++++++ src/base/DeadCodeDetector.ml | 15 ++++++++------- src/base/Disambiguate.ml | 5 +++++ src/base/Gas.ml | 2 +- src/base/ParserUtil.ml | 1 + src/base/PatternChecker.ml | 1 + src/base/Recursion.ml | 1 + src/base/SanityChecker.ml | 28 +++++++++++++++------------- src/base/ScillaLexer.mll | 1 + src/base/ScillaParser.mly | 2 ++ src/base/Syntax.ml | 4 ++++ src/base/SyntaxAnnotMapper.ml | 1 + src/base/TypeChecker.ml | 19 +++++++++++++++++++ src/base/TypeInfo.ml | 2 +- src/eval/Eval.ml | 3 +++ src/formatter/ExtendedSyntax.ml | 7 ++++++- src/formatter/Formatter.ml | 3 +++ src/merge/Merge.ml | 7 +++++-- 21 files changed, 98 insertions(+), 30 deletions(-) diff --git a/deps/cryptoutils/src b/deps/cryptoutils/src index b095d6321..dd12237ba 160000 --- a/deps/cryptoutils/src +++ b/deps/cryptoutils/src @@ -1 +1 @@ -Subproject commit b095d632184dabcaa1886125f07c94c6a142c072 +Subproject commit dd12237ba264605013c44c4c9ec136bddc350987 diff --git a/src/base/Accept.ml b/src/base/Accept.ml index ba37922d8..f59e38241 100644 --- a/src/base/Accept.ml +++ b/src/base/Accept.ml @@ -117,8 +117,9 @@ struct @ List.fold_left stmts ~init:[] ~f:(fun acc s -> acc @ walk_stmt s)) | Load _ | RemoteLoad _ | Store _ | MapUpdate _ | MapGet _ - | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | Iterate _ - | SendMsgs _ | CreateEvnt _ | CallProc _ | Throw _ | GasStmt _ -> + | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | Return _ + | Iterate _ | SendMsgs _ | CreateEvnt _ | CallProc _ | Throw _ + | GasStmt _ -> [] in List.fold_left comp.comp_body ~init:[] ~f:(fun acc s -> acc @ walk_stmt s) diff --git a/src/base/Callgraph.ml b/src/base/Callgraph.ml index 89dc0ddc6..5c5c633a4 100644 --- a/src/base/Callgraph.ml +++ b/src/base/Callgraph.ml @@ -197,8 +197,8 @@ module ScillaCallgraph (SR : Rep) (ER : Rep) = struct NodeSet.union acc @@ visit_stmt sa) |> NodeSet.union acc) | Load _ | RemoteLoad _ | Store _ | MapUpdate _ | MapGet _ - | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | SendMsgs _ - | CreateEvnt _ | Throw _ | GasStmt _ -> + | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | Return _ + | SendMsgs _ | CreateEvnt _ | Throw _ | GasStmt _ -> emp_nodes_set in List.fold_left comp.comp_body ~init:emp_nodes_set ~f:(fun acc s -> diff --git a/src/base/Cashflow.ml b/src/base/Cashflow.ml index ff82a1368..43e7721a7 100644 --- a/src/base/Cashflow.ml +++ b/src/base/Cashflow.ml @@ -227,6 +227,7 @@ struct | TypeCast (x, r, t) -> CFSyntax.TypeCast (add_noinfo_to_ident x, add_noinfo_to_ident r, t) | AcceptPayment -> CFSyntax.AcceptPayment + | Return i -> CFSyntax.Return (add_noinfo_to_ident i) | SendMsgs x -> CFSyntax.SendMsgs (add_noinfo_to_ident x) | CreateEvnt x -> CFSyntax.CreateEvnt (add_noinfo_to_ident x) | CallProc (p, args) -> @@ -1870,6 +1871,20 @@ struct || [%equal: ECFR.money_tag] (get_id_tag r) r_tag) ) | AcceptPayment -> (AcceptPayment, param_env, field_env, local_env, ctr_tag_map, false) + | Return i -> + let i_tag = + lub_tags NotMoney (lookup_var_tag2 i local_env param_env) + in + let new_i = update_id_tag i i_tag in + let new_local_env, new_param_env = + update_var_tag2 i i_tag local_env param_env + in + ( Return new_i, + new_param_env, + field_env, + new_local_env, + ctr_tag_map, + not @@ [%equal: ECFR.money_tag] (get_id_tag i) i_tag ) | GasStmt g -> (GasStmt g, param_env, field_env, local_env, ctr_tag_map, false) | SendMsgs m -> diff --git a/src/base/DeadCodeDetector.ml b/src/base/DeadCodeDetector.ml index 62b0947df..a43ad9b8d 100644 --- a/src/base/DeadCodeDetector.ml +++ b/src/base/DeadCodeDetector.ml @@ -260,8 +260,9 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct | Bind (_, e) -> report_expr e | MatchStmt (_, pslist) -> List.iter pslist ~f:report_unreachable_adapter | Load _ | RemoteLoad _ | Store _ | MapUpdate _ | MapGet _ - | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | GasStmt _ - | Throw _ | Iterate _ | CallProc _ | CreateEvnt _ | SendMsgs _ -> + | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | Return _ + | GasStmt _ | Throw _ | Iterate _ | CallProc _ | CreateEvnt _ | SendMsgs _ + -> () in Option.iter cmod.libs ~f:(fun l -> @@ -491,7 +492,7 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct warn "Unused type cast statement to: " x ER.get_loc; (ERSet.add lv r, adts, ctrs)) | SendMsgs v | CreateEvnt v -> (ERSet.add lv v, adts, ctrs) - | AcceptPayment | GasStmt _ -> (lv, adts, ctrs)) + | AcceptPayment | Return _ | GasStmt _ -> (lv, adts, ctrs)) | _ -> (emp_erset, emp_idset, emp_idset) (** Checks for unused module's components. @@ -548,8 +549,8 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct get_used_address_fields address_params sa |> merge_id_maps m) |> merge_id_maps m) | Bind _ | Load _ | Store _ | MapUpdate _ | MapGet _ | ReadFromBC _ - | TypeCast _ | AcceptPayment | Iterate _ | SendMsgs _ | CreateEvnt _ - | CallProc _ | Throw _ | GasStmt _ -> + | TypeCast _ | AcceptPayment | Return _ | Iterate _ | SendMsgs _ + | CreateEvnt _ | CallProc _ | Throw _ | GasStmt _ -> emp_idsmap (** Returns a set of field names of the contract address type. *) @@ -794,8 +795,8 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct Map.set used ~key:ctr_name ~data:ctr_arg_pos_to_fields' | _ -> used) | Bind _ | Load _ | Store _ | MapUpdate _ | MapGet _ | ReadFromBC _ - | TypeCast _ | AcceptPayment | Iterate _ | SendMsgs _ | CreateEvnt _ - | CallProc _ | Throw _ | GasStmt _ -> + | TypeCast _ | AcceptPayment | Return _ | Iterate _ | SendMsgs _ + | CreateEvnt _ | CallProc _ | Throw _ | GasStmt _ -> used in List.fold_left comp.comp_body ~init:used ~f:(fun used s -> aux used s) diff --git a/src/base/Disambiguate.ml b/src/base/Disambiguate.ml index e27306a36..234942928 100644 --- a/src/base/Disambiguate.ml +++ b/src/base/Disambiguate.ml @@ -678,6 +678,11 @@ module ScillaDisambiguation (SR : Rep) (ER : Rep) = struct in pure @@ (PostDisSyntax.TypeCast (dis_x, dis_r, dis_t), new_var_dict) | AcceptPayment -> pure @@ (PostDisSyntax.AcceptPayment, var_dict_acc) + | Return i -> + let%bind dis_i = + disambiguate_identifier_helper var_dict_acc (SR.get_loc rep) i + in + pure @@ (PostDisSyntax.Return dis_i, var_dict_acc) | Iterate (l, proc) -> let%bind dis_l = disambiguate_identifier_helper var_dict_acc (SR.get_loc rep) l diff --git a/src/base/Gas.ml b/src/base/Gas.ml index 0926b361e..b5820d4b5 100644 --- a/src/base/Gas.ml +++ b/src/base/Gas.ml @@ -238,7 +238,7 @@ module ScillaGas (SR : Rep) (ER : Rep) = struct in let s' = MatchStmt (x, clauses') in pure @@ [ (GasStmt g, srep); (s', srep) ] - | AcceptPayment -> + | AcceptPayment | Return _ -> let g = GasStmt (GasGasCharge.StaticCost 1) in pure @@ [ (g, srep); (s, srep) ] | Iterate (l, _) -> diff --git a/src/base/ParserUtil.ml b/src/base/ParserUtil.ml index 2b6646f91..9a5577307 100644 --- a/src/base/ParserUtil.ml +++ b/src/base/ParserUtil.ml @@ -134,6 +134,7 @@ module type Syn = sig | TypeCast of ParserRep.rep SIdentifier.t * ParserRep.rep SIdentifier.t * SType.t | AcceptPayment + | Return of ParserRep.rep SIdentifier.t (* forall l p *) | Iterate of ParserRep.rep SIdentifier.t * ParserRep.rep SIdentifier.t | SendMsgs of ParserRep.rep SIdentifier.t diff --git a/src/base/PatternChecker.ml b/src/base/PatternChecker.ml index aee1d7b48..29240e7d6 100644 --- a/src/base/PatternChecker.ml +++ b/src/base/PatternChecker.ml @@ -282,6 +282,7 @@ struct | TypeCast (x, r, t) -> pure @@ (CheckedPatternSyntax.TypeCast (x, r, t), rep) | AcceptPayment -> pure @@ (CheckedPatternSyntax.AcceptPayment, rep) + | Return i -> pure @@ (CheckedPatternSyntax.Return i, rep) | Iterate (l, p) -> pure @@ (CheckedPatternSyntax.Iterate (l, p), rep) | SendMsgs i -> pure @@ (CheckedPatternSyntax.SendMsgs i, rep) | CreateEvnt i -> pure @@ (CheckedPatternSyntax.CreateEvnt i, rep) diff --git a/src/base/Recursion.ml b/src/base/Recursion.ml index 1dc2a3221..45be728f8 100644 --- a/src/base/Recursion.ml +++ b/src/base/Recursion.ml @@ -214,6 +214,7 @@ module ScillaRecursion (SR : Rep) (ER : Rep) = struct pure @@ RecursionSyntax.ReadFromBC (x, recursion_bcinfo f) | TypeCast (x, r, t) -> pure @@ RecursionSyntax.TypeCast (x, r, t) | AcceptPayment -> pure @@ RecursionSyntax.AcceptPayment + | Return i -> pure @@ RecursionSyntax.Return i | Iterate (l, p) -> pure @@ RecursionSyntax.Iterate (l, p) | SendMsgs msg -> pure @@ RecursionSyntax.SendMsgs msg | CreateEvnt evnt -> pure @@ RecursionSyntax.CreateEvnt evnt diff --git a/src/base/SanityChecker.ml b/src/base/SanityChecker.ml index aa7065830..9e985fea1 100644 --- a/src/base/SanityChecker.ml +++ b/src/base/SanityChecker.ml @@ -382,8 +382,9 @@ struct | TypeCast (x, _, _) -> check_warn_redef cparams cfields pnames stmt_defs x; pure (get_id x :: acc_stmt_defs) - | Store _ | MapUpdate _ | SendMsgs _ | AcceptPayment | GasStmt _ - | CreateEvnt _ | Throw _ | CallProc _ | Iterate _ -> + | Store _ | MapUpdate _ | SendMsgs _ | AcceptPayment | Return _ + (* the return identifier will be checked at its definition *) + | GasStmt _ | CreateEvnt _ | Throw _ | CallProc _ | Iterate _ -> pure acc_stmt_defs | Bind (x, e) -> check_warn_redef cparams cfields pnames stmt_defs x; @@ -480,7 +481,7 @@ struct forallM clauses ~f:(fun (_pat, mbody) -> stmt_iter mbody) | Load _ | RemoteLoad _ | MapGet _ | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | Store _ | MapUpdate _ | SendMsgs _ - | AcceptPayment | GasStmt _ | CreateEvnt _ | Throw _ + | AcceptPayment | Return _ | GasStmt _ | CreateEvnt _ | Throw _ | CallProc _ | Iterate _ -> pure ()) in @@ -562,8 +563,8 @@ struct else [] (* We shouldn't handle `forall` here, because it operates only with iterables. *) | Iterate _ | Load _ | RemoteLoad _ | Store _ | MapUpdate _ | MapGet _ - | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | SendMsgs _ - | CreateEvnt _ | Throw _ | GasStmt _ -> + | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | Return _ + | SendMsgs _ | CreateEvnt _ | Throw _ | GasStmt _ -> [] let id_is_unboxed unboxed_options id = @@ -602,7 +603,8 @@ struct |> List.append acc) | Store _ | MapUpdate _ | CallProc _ | Bind _ | Iterate _ | Load _ | RemoteLoad _ | MapGet _ | RemoteMapGet _ | ReadFromBC _ | TypeCast _ - | AcceptPayment | SendMsgs _ | CreateEvnt _ | Throw _ | GasStmt _ -> + | AcceptPayment | Return _ | SendMsgs _ | CreateEvnt _ | Throw _ + | GasStmt _ -> [] (** Returns a list of variables from [unboxed_options] that are used as @@ -646,7 +648,7 @@ struct |> List.append acc) | Store _ | MapUpdate _ | CallProc _ | Iterate _ | Load _ | RemoteLoad _ | MapGet _ | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment - | SendMsgs _ | CreateEvnt _ | Throw _ | GasStmt _ -> + | Return _ | SendMsgs _ | CreateEvnt _ | Throw _ | GasStmt _ -> [] (** Returns names of variables that are matched in the expression. *) @@ -693,8 +695,8 @@ struct (* We shouldn't handle `forall` here, because it operates only with iterables. *) | Iterate _ -> [] | Load _ | RemoteLoad _ | Store _ | MapUpdate _ | MapGet _ - | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | SendMsgs _ - | CreateEvnt _ | Throw _ | GasStmt _ -> + | RemoteMapGet _ | ReadFromBC _ | TypeCast _ | AcceptPayment | Return _ + | SendMsgs _ | CreateEvnt _ | Throw _ | GasStmt _ -> [] (** Collects function calls that don't call type functions directly or @@ -806,8 +808,8 @@ struct | MapGet (v, _, _, true) | RemoteMapGet (v, _, _, _, true) -> [ v ] | MapGet _ | RemoteMapGet _ | Load _ | RemoteLoad _ | Store _ | Bind _ | MapUpdate _ | MatchStmt _ | ReadFromBC _ | TypeCast _ | AcceptPayment - | Iterate _ | SendMsgs _ | CreateEvnt _ | CallProc _ | Throw _ | GasStmt _ - -> + | Return _ | Iterate _ | SendMsgs _ | CreateEvnt _ | CallProc _ | Throw _ + | GasStmt _ -> [] (** Collects different names for the not unboxed option values. *) @@ -826,8 +828,8 @@ struct | _ -> []) | MapGet _ | RemoteMapGet _ | Load _ | RemoteLoad _ | Store _ | MapUpdate _ | MatchStmt _ | ReadFromBC _ | TypeCast _ | AcceptPayment - | Iterate _ | SendMsgs _ | CreateEvnt _ | CallProc _ | Throw _ | GasStmt _ - -> + | Return _ | Iterate _ | SendMsgs _ | CreateEvnt _ | CallProc _ | Throw _ + | GasStmt _ -> [] (** Collects not matched local variables returned from map get operations diff --git a/src/base/ScillaLexer.mll b/src/base/ScillaLexer.mll index 57000f6f0..576dc0e11 100644 --- a/src/base/ScillaLexer.mll +++ b/src/base/ScillaLexer.mll @@ -88,6 +88,7 @@ rule read = | "event" { EVENT } | "field" { FIELD } | "accept" { ACCEPT } + | "return" { RETURN } | "exists" { EXISTS } | "delete" { DELETE } | "Emp" { EMP } diff --git a/src/base/ScillaParser.mly b/src/base/ScillaParser.mly index 475c3164f..3d3afdbfe 100644 --- a/src/base/ScillaParser.mly +++ b/src/base/ScillaParser.mly @@ -154,6 +154,7 @@ %token SEND %token EVENT %token ACCEPT +%token RETURN %token MAP %token DELETE %token EXISTS @@ -422,6 +423,7 @@ stmt: | DELETE; l = ID; keys = nonempty_list(map_access) { MapUpdate( to_loc_id l (toLoc $startpos(l)), keys, None), toLoc $startpos } | ACCEPT { (AcceptPayment, toLoc $startpos) } +| RETURN; i = sid; { (Return (ParserIdentifier.mk_id i (toLoc $startpos(i))), toLoc $startpos) } | SEND; m = sid; { (SendMsgs (ParserIdentifier.mk_id m (toLoc $startpos(m))), toLoc $startpos) } | EVENT; m = sid; { (CreateEvnt (ParserIdentifier.mk_id m (toLoc $startpos(m))), toLoc $startpos) } | THROW; mopt = option(sid); { Throw (Core.Option.map mopt ~f:(fun m -> (ParserIdentifier.mk_id m (toLoc $startpos(mopt))))), toLoc $startpos } diff --git a/src/base/Syntax.ml b/src/base/Syntax.ml index 4ac599a4b..5c6fd36a4 100644 --- a/src/base/Syntax.ml +++ b/src/base/Syntax.ml @@ -360,6 +360,8 @@ module ScillaSyntax (SR : Rep) (ER : Rep) (Lit : ScillaLiteral) = struct | TypeCast of ER.rep SIdentifier.t * ER.rep SIdentifier.t * SType.t (** [TypeCast(I, A, TY)] represents: [I <- & A as TY] *) | AcceptPayment (** [AcceptPayment] is an [accept] statement. *) + | Return of ER.rep SIdentifier.t + (** [Return(A)] is an [return A] statement *) | Iterate of ER.rep SIdentifier.t * SR.rep SIdentifier.t (** [Iterate(L, F)] represents calling a procedure for each element of the list: [forall L F] *) @@ -638,6 +640,8 @@ module ScillaSyntax (SR : Rep) (ER : Rep) (Lit : ScillaLiteral) = struct sprintf "Error casting `%s` into type `%s`:\n" (as_error_string x) (SType.pp_typ_error t) | AcceptPayment -> sprintf "Error in accepting payment\n" + | Return i -> + sprintf "Error in returning value `%s`\n" (as_error_string i) | Iterate (l, p) -> sprintf "Error iterating `%s` over elements in list `%s`:\n" (as_error_string p) (as_error_string l) diff --git a/src/base/SyntaxAnnotMapper.ml b/src/base/SyntaxAnnotMapper.ml index 70bb53c74..76bb062cf 100644 --- a/src/base/SyntaxAnnotMapper.ml +++ b/src/base/SyntaxAnnotMapper.ml @@ -216,6 +216,7 @@ struct | TypeCast (id, addr, ty) -> OutputSyntax.TypeCast (map_id fe id, map_id fe addr, map_type ty ~fl) | AcceptPayment -> OutputSyntax.AcceptPayment + | Return i -> OutputSyntax.Return (map_id fe i) | Iterate (list, proc) -> OutputSyntax.Iterate (map_id fe list, map_id fs proc) | SendMsgs id -> OutputSyntax.SendMsgs (map_id fe id) diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 3f631228c..9a17be707 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -911,6 +911,25 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct @@ add_stmt_to_stmts_env_gas (TypedSyntax.AcceptPayment, rep) checked_stmts + | Return i -> + let%bind r = + fromR_TE + @@ TEnv.resolveT env.pure (get_id i) ~lopt:(Some (get_rep i)) + in + let i_type = rr_typ r in + (* TODO: Look the return type of the procedure in the env. *) + (* let expected = () in *) + (* let%bind () = *) + (* fromR_TE *) + (* @@ assert_type_assignable ~expected ~actual:i_type.tp *) + (* ~lc:(ER.get_loc (get_rep i)) *) + (* in *) + let typed_i = add_type_to_ident i i_type in + let%bind checked_stmts = type_stmts sts get_loc env in + pure + @@ add_stmt_to_stmts_env_gas + (TypedSyntax.Return typed_i, rep) + checked_stmts | SendMsgs i -> let%bind r = fromR_TE diff --git a/src/base/TypeInfo.ml b/src/base/TypeInfo.ml index 5ee45cf03..4e7580134 100644 --- a/src/base/TypeInfo.ml +++ b/src/base/TypeInfo.ml @@ -125,7 +125,7 @@ struct patternsts @ branchts) in ots :: List.concat clausets - | SendMsgs v | CreateEvnt v -> [ calc_ident_locs v ] + | SendMsgs v | CreateEvnt v | Return v -> [ calc_ident_locs v ] | ReadFromBC (v, bf) -> List.map ~f:calc_ident_locs (v diff --git a/src/eval/Eval.ml b/src/eval/Eval.ml index 42cf68bc8..cdd422a9f 100644 --- a/src/eval/Eval.ml +++ b/src/eval/Eval.ml @@ -470,6 +470,9 @@ let rec stmt_eval conf stmts = | AcceptPayment -> let%bind conf' = Configuration.accept_incoming conf in stmt_eval conf' sts + | Return _id -> (* TODO *) + let%bind conf' = Configuration.accept_incoming conf in + stmt_eval conf' sts (* Caution emitting messages does not change balance immediately! *) | SendMsgs ms -> let%bind ms_resolved = fromR @@ Configuration.lookup conf ms in diff --git a/src/formatter/ExtendedSyntax.ml b/src/formatter/ExtendedSyntax.ml index b1171579f..e0d752398 100644 --- a/src/formatter/ExtendedSyntax.ml +++ b/src/formatter/ExtendedSyntax.ml @@ -103,7 +103,8 @@ struct ER.rep id_ann * (pattern * stmt_annot list * comment_text list) list | ReadFromBC of ER.rep id_ann * bcinfo_query | TypeCast of ER.rep id_ann * ER.rep id_ann * SType.t - | AcceptPayment (** [AcceptPayment] is an [accept] statement. *) + | AcceptPayment + | Return of ER.rep id_ann | Iterate of ER.rep id_ann * SR.rep id_ann | SendMsgs of ER.rep id_ann | CreateEvnt of ER.rep id_ann @@ -640,6 +641,10 @@ struct | Syn.AcceptPayment -> let c = comment (SR.get_loc ann) in (ExtSyn.AcceptPayment, ann, c) + | Syn.Return id -> + let c = comment (loc_end_er id) in + let id' = extend_er_id tr id in + (ExtSyn.Return id', ann, c) | Syn.Iterate (l, f) -> let c = comment (loc_end_er l) in let l' = extend_er_id tr l in diff --git a/src/formatter/Formatter.ml b/src/formatter/Formatter.ml index 12865e1ba..9e7803ca9 100644 --- a/src/formatter/Formatter.ml +++ b/src/formatter/Formatter.ml @@ -58,6 +58,7 @@ struct let delete_kwd = !^"delete" let exists_kwd = !^"exists" let accept_kwd = !^"accept" + let return_kwd = !^"return" let as_kwd = !^"as" let send_kwd = !^"send" let event_kwd = !^"event" @@ -423,6 +424,8 @@ struct of_ann_id id ^^^ blockchain_arrow ^//^ of_ann_id addr ^^^ as_kwd ^^^ of_type typ | Ast.AcceptPayment -> accept_kwd + | Ast.Return id -> + return_kwd ^//^ of_ann_id id | Ast.Iterate (arg_list, proc) -> (* forall l p *) forall_kwd ^//^ of_ann_id arg_list ^//^ of_ann_id proc diff --git a/src/merge/Merge.ml b/src/merge/Merge.ml index 85bcdadad..f080e5c9d 100644 --- a/src/merge/Merge.ml +++ b/src/merge/Merge.ml @@ -475,6 +475,9 @@ module ScillaMerger (SR : Rep) (ER : Rep) = struct | ReadFromBC (id, q) -> let id' = rename_local_er renames_map id in (ReadFromBC (id', q), annot) + | Return id -> + let id' = rename_local_er renames_map id in + (Return id', annot) | AcceptPayment | SendMsgs _ | CreateEvnt _ | Throw _ | GasStmt _ -> (stmt, annot) @@ -749,8 +752,8 @@ module ScillaMerger (SR : Rep) (ER : Rep) = struct in (Bind (id', body), annot) | Load _ | Store _ | Bind _ | MapUpdate _ | MapGet _ | ReadFromBC _ - | AcceptPayment | Iterate _ | SendMsgs _ | CreateEvnt _ | CallProc _ - | Throw _ | GasStmt _ -> + | AcceptPayment | Return _ | Iterate _ | SendMsgs _ | CreateEvnt _ + | CallProc _ | Throw _ | GasStmt _ -> (stmt, annot) let localize_comp renames_map comp = From 973658d8b66c13e9fffa92dce0908089118e2395 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 26 Oct 2022 17:36:43 +0700 Subject: [PATCH 02/41] feat(all): Add return type to procedures --- src/base/Cashflow.ml | 8 ++++++-- src/base/Disambiguate.ml | 10 +++++++++- src/base/ParserUtil.ml | 1 + src/base/PatternChecker.ml | 3 ++- src/base/Recursion.ml | 3 ++- src/base/ScillaParser.mly | 10 ++++++++-- src/base/Syntax.ml | 1 + src/base/SyntaxAnnotMapper.ml | 4 +++- src/base/TypeChecker.ml | 3 ++- 9 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/base/Cashflow.ml b/src/base/Cashflow.ml index 43e7721a7..51cbab988 100644 --- a/src/base/Cashflow.ml +++ b/src/base/Cashflow.ml @@ -242,13 +242,16 @@ struct (res_s, rep) let cf_init_tag_component component = - let { comp_type; comp_name; comp_params; comp_body } = component in + let { comp_type; comp_name; comp_params; comp_body; comp_return } = + component + in { CFSyntax.comp_type; CFSyntax.comp_name; CFSyntax.comp_params = List.map ~f:(fun (x, t) -> (add_noinfo_to_ident x, t)) comp_params; CFSyntax.comp_body = List.map ~f:cf_init_tag_stmt comp_body; + CFSyntax.comp_return; } let cf_init_tag_contract contract token_fields = @@ -2006,7 +2009,7 @@ struct new_changes || acc_changes )) let cf_tag_component t param_env field_env ctr_tag_map = - let { comp_type; comp_name; comp_params; comp_body } = t in + let { comp_type; comp_name; comp_params; comp_body; comp_return } = t in let empty_local_env = AssocDictionary.make_dict () in let implicit_local_env = AssocDictionary.insert MessagePayload.amount_label Money @@ -2041,6 +2044,7 @@ struct comp_name; comp_params = new_params; comp_body = new_comp_body; + comp_return; }, new_param_env, new_field_env, diff --git a/src/base/Disambiguate.ml b/src/base/Disambiguate.ml index 234942928..b11b2c8e1 100644 --- a/src/base/Disambiguate.ml +++ b/src/base/Disambiguate.ml @@ -736,7 +736,7 @@ module ScillaDisambiguation (SR : Rep) (ER : Rep) = struct (**************************************************************) let disambiguate_component (dicts : name_dicts) comp = - let { comp_type; comp_name; comp_params; comp_body } = comp in + let { comp_type; comp_name; comp_params; comp_body; comp_return } = comp in let%bind dis_comp_name = name_def_as_simple_global comp_name in let%bind dis_comp_params = mapM comp_params ~f:(fun (x, t) -> @@ -751,6 +751,13 @@ module ScillaDisambiguation (SR : Rep) (ER : Rep) = struct remove_local_id_from_dict dict (as_string x)) in let body_dicts = { dicts with var_dict = body_var_dict } in + let%bind dis_return = + match comp_return with + | None -> pure None + | Some ret -> + let%bind dis_t = disambiguate_type dicts.typ_dict ret in + pure (Some dis_t) + in let%bind dis_comp_body = disambiguate_stmts body_dicts comp_body in pure @@ { @@ -758,6 +765,7 @@ module ScillaDisambiguation (SR : Rep) (ER : Rep) = struct PostDisSyntax.comp_name = dis_comp_name; PostDisSyntax.comp_params = dis_comp_params; PostDisSyntax.comp_body = dis_comp_body; + PostDisSyntax.comp_return = dis_return; } (**************************************************************) diff --git a/src/base/ParserUtil.ml b/src/base/ParserUtil.ml index 9a5577307..528d94af3 100644 --- a/src/base/ParserUtil.ml +++ b/src/base/ParserUtil.ml @@ -152,6 +152,7 @@ module type Syn = sig comp_name : ParserRep.rep SIdentifier.t; comp_params : (ParserRep.rep SIdentifier.t * SType.t) list; comp_body : stmt_annot list; + comp_return : SType.t option; } type ctr_def = { diff --git a/src/base/PatternChecker.ml b/src/base/PatternChecker.ml index 29240e7d6..663c35898 100644 --- a/src/base/PatternChecker.ml +++ b/src/base/PatternChecker.ml @@ -296,7 +296,7 @@ struct pure @@ (checked_s :: checked_stmts) let pm_check_component t = - let { comp_type; comp_name; comp_params; comp_body } = t in + let { comp_type; comp_name; comp_params; comp_body; comp_return } = t in let kind = "Error during pattern-match checking of component" and inst = sprintf "%s %s:\n" @@ -313,6 +313,7 @@ struct CheckedPatternSyntax.comp_name; CheckedPatternSyntax.comp_params; CheckedPatternSyntax.comp_body = checked_body; + CheckedPatternSyntax.comp_return; } let pm_check_libentries lentries = diff --git a/src/base/Recursion.ml b/src/base/Recursion.ml index 45be728f8..10b1d0406 100644 --- a/src/base/Recursion.ml +++ b/src/base/Recursion.ml @@ -232,7 +232,7 @@ module ScillaRecursion (SR : Rep) (ER : Rep) = struct walk srep let recursion_component is_proc_in_scope comp = - let { comp_type; comp_name; comp_params; comp_body } = comp in + let { comp_type; comp_name; comp_params; comp_body; comp_return } = comp in let%bind () = forallM ~f:(fun (_, t) -> recursion_typ t) comp_params in let%bind recursion_comp_body = mapM ~f:(fun s -> recursion_stmt is_proc_in_scope s) comp_body @@ -243,6 +243,7 @@ module ScillaRecursion (SR : Rep) (ER : Rep) = struct RecursionSyntax.comp_name; RecursionSyntax.comp_params; RecursionSyntax.comp_body = recursion_comp_body; + RecursionSyntax.comp_return; } let recursion_contract c = diff --git a/src/base/ScillaParser.mly b/src/base/ScillaParser.mly index 3d3afdbfe..244609364 100644 --- a/src/base/ScillaParser.mly +++ b/src/base/ScillaParser.mly @@ -479,11 +479,16 @@ component: procedure: | PROCEDURE; t = component_id; params = component_params; + ret = option(return_type); ss = component_body; { { comp_type = CompProc; comp_name = t; comp_params = params; - comp_body = ss } } + comp_body = ss; + comp_return = ret } } + +return_type: +| LPAREN; t = type_annot; RPAREN; { t } transition: | TRANSITION; t = component_id; @@ -492,7 +497,8 @@ transition: { { comp_type = CompTrans; comp_name = t; comp_params = params; - comp_body = ss } } + comp_body = ss; + comp_return = None; } } component_id: | c = CID { to_loc_id c (toLoc $startpos(c)) } diff --git a/src/base/Syntax.ml b/src/base/Syntax.ml index 5c6fd36a4..9dd7f4a9d 100644 --- a/src/base/Syntax.ml +++ b/src/base/Syntax.ml @@ -391,6 +391,7 @@ module ScillaSyntax (SR : Rep) (ER : Rep) (Lit : ScillaLiteral) = struct comp_name : SR.rep SIdentifier.t; comp_params : (ER.rep SIdentifier.t * SType.t) list; comp_body : stmt_annot list; + comp_return : SType.t option; } [@@deriving sexp] diff --git a/src/base/SyntaxAnnotMapper.ml b/src/base/SyntaxAnnotMapper.ml index 76bb062cf..afced3400 100644 --- a/src/base/SyntaxAnnotMapper.ml +++ b/src/base/SyntaxAnnotMapper.ml @@ -251,7 +251,8 @@ struct OutputSyntax.LibTyp (map_id fe ty_id, List.map ctr_defs ~f:(fun cd -> ctr_def cd ~fe ~fl)) - let component { comp_type; comp_name; comp_params; comp_body } ~fe ~fl ~fs = + let component { comp_type; comp_name; comp_params; comp_body; comp_return } + ~fe ~fl ~fs = OutputSyntax. { comp_type; @@ -260,6 +261,7 @@ struct List.map comp_params ~f:(fun (param, ty) -> (map_id fe param, map_type ty ~fl)); comp_body = statements_annot comp_body ~fe ~fl ~fs; + comp_return; } let contract { cname; cparams; cconstraint; cfields; ccomps } ~fe ~fs ~fl = diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 9a17be707..8f24339fd 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -1055,7 +1055,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct pure @@ (new_p, new_stmts) let type_component env0 tr = - let { comp_type; comp_name; comp_params; comp_body } = tr in + let { comp_type; comp_name; comp_params; comp_body; comp_return } = tr in let procedures = env0.procedures in let component_type_string = component_type_to_string comp_type in let param_checker = @@ -1097,6 +1097,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct TypedSyntax.comp_name; TypedSyntax.comp_params = typed_cparams; TypedSyntax.comp_body = typed_stmts; + TypedSyntax.comp_return; }, new_proc_signatures ) From 44acbbbeaa6b8576c592828ec7ba8fc3f6b3ba69 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 27 Oct 2022 13:31:13 +0700 Subject: [PATCH 03/41] =?UTF-8?q?chore(parser):=20Return=20syntax:=20`proc?= =?UTF-8?q?edure=20p()=20=E2=86=92=20String`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/ScillaParser.mly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/ScillaParser.mly b/src/base/ScillaParser.mly index 244609364..e548aa376 100644 --- a/src/base/ScillaParser.mly +++ b/src/base/ScillaParser.mly @@ -488,7 +488,7 @@ procedure: comp_return = ret } } return_type: -| LPAREN; t = type_annot; RPAREN; { t } +| TARROW; t = typ; { t } transition: | TRANSITION; t = component_id; From 6ff412ab1b65526c4580c2e36e7754aab45680d2 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 27 Oct 2022 13:32:03 +0700 Subject: [PATCH 04/41] feat(tc): Support procedures w/ return types We use cram tests for this, because the checker cannot create a JSON dump of errors if they occurred on the typechecking step. --- src/base/TypeChecker.ml | 101 +++++++++++------- tests/checker/bad/Bad.ml | 1 + tests/typecheck/contracts.t/run.t | 9 ++ .../contracts.t/typecheck-return-1.scilla | 15 +++ .../typecheck-return-1.scilla.gold | 5 + 5 files changed, 90 insertions(+), 41 deletions(-) create mode 100644 tests/typecheck/contracts.t/run.t create mode 100644 tests/typecheck/contracts.t/typecheck-return-1.scilla create mode 100644 tests/typecheck/contracts.t/typecheck-return-1.scilla.gold diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 8f24339fd..182185f8e 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -619,7 +619,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let get_tenv_fields env = env.fields let get_tenv_pure env = env.pure - let rec type_stmts stmts get_loc env = + let rec type_stmts comp stmts get_loc env = let open Datatypes.DataTypeDictionary in match stmts with | [] -> pure ([], env) @@ -635,7 +635,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct in let%bind checked_stmts = with_extended_env env get_tenv_pure [ pure' ] [] - (type_stmts sts get_loc) + (type_stmts comp sts get_loc) in let typed_x = add_type_to_ident x ident_type in let typed_f = add_type_to_ident f ident_type in @@ -657,7 +657,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct in let%bind checked_stmts = with_extended_env env get_tenv_pure [ pure' ] [] - (type_stmts sts get_loc) + (type_stmts comp sts get_loc) in let typed_x = add_type_to_ident x ident_type in let typed_adr = add_type_to_ident adr adr_type in @@ -690,7 +690,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~actual:(rr_typ rr).tp ~lc:(ER.get_loc (get_rep r)) in - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ (checked_stmts, rr_typ fr, rr_typ rr) in let typed_f = add_type_to_ident f f_type in @@ -704,7 +704,8 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let%bind checked_stmts = with_extended_env env get_tenv_pure [ (x, ityp.tp) ] - [] (type_stmts sts get_loc) + [] + (type_stmts comp sts get_loc) in let typed_x = add_type_to_ident x ityp in pure @@ -740,7 +741,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct pure @@ (typed_m, typed_klist, typed_v) in (* Check rest of the statements. *) - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in (* Update annotations. *) pure @@ add_stmt_to_stmts_env_gas @@ -761,7 +762,8 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let%bind checked_stmts = with_extended_env env get_tenv_pure [ (v, v_type') ] - [] (type_stmts sts get_loc) + [] + (type_stmts comp sts get_loc) in (* Update annotations. *) pure @@ -784,7 +786,8 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let%bind checked_stmts = with_extended_env env get_tenv_pure [ (v, v_type') ] - [] (type_stmts sts get_loc) + [] + (type_stmts comp sts get_loc) in pure @@ add_stmt_to_stmts_env_gas @@ -838,7 +841,8 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let%bind checked_stmts = with_extended_env env get_tenv_pure [ (x, bt) ] - [] (type_stmts sts get_loc) + [] + (type_stmts comp sts get_loc) in let typed_x = add_type_to_ident x (mk_qual_tp bt) in pure @@ -871,7 +875,8 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let%bind checked_stmts = with_extended_env env get_tenv_pure [ (x, res_typ.tp) ] - [] (type_stmts sts get_loc) + [] + (type_stmts comp sts get_loc) in pure @@ add_stmt_to_stmts_env_gas @@ -895,41 +900,55 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let%bind checked_clauses_rev = foldM clauses ~init:[] ~f:(fun checked_clauses_acc (ptrn, ex) -> let%bind typed_clause = - type_match_stmt_branch env sct ptrn ex get_loc + type_match_stmt_branch comp env sct ptrn ex get_loc in pure @@ (typed_clause :: checked_clauses_acc)) in let checked_clauses = List.rev checked_clauses_rev in - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.MatchStmt (typed_x, checked_clauses), rep) checked_stmts | AcceptPayment -> - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.AcceptPayment, rep) checked_stmts - | Return i -> - let%bind r = - fromR_TE - @@ TEnv.resolveT env.pure (get_id i) ~lopt:(Some (get_rep i)) - in - let i_type = rr_typ r in - (* TODO: Look the return type of the procedure in the env. *) - (* let expected = () in *) - (* let%bind () = *) - (* fromR_TE *) - (* @@ assert_type_assignable ~expected ~actual:i_type.tp *) - (* ~lc:(ER.get_loc (get_rep i)) *) - (* in *) - let typed_i = add_type_to_ident i i_type in - let%bind checked_stmts = type_stmts sts get_loc env in - pure - @@ add_stmt_to_stmts_env_gas - (TypedSyntax.Return typed_i, rep) - checked_stmts + | Return i -> ( + match (comp.comp_type, comp.comp_return) with + | CompTrans, _ -> + fail + (mk_type_error1 + ~kind:"Return statements in transition are prohibited" + (SR.get_loc rep)) + | CompProc, None -> + fail + (mk_type_error1 + ~kind: + (Printf.sprintf + "Procedure %s cannot return because it doesn't have \ + a return type" + (as_error_string comp.comp_name)) + (SR.get_loc rep)) + | CompProc, Some ret -> + let%bind r = + fromR_TE + @@ TEnv.resolveT env.pure (get_id i) ~lopt:(Some (get_rep i)) + in + let i_type = rr_typ r in + let%bind () = + fromR_TE + @@ assert_type_assignable ~expected:ret ~actual:i_type.tp + ~lc:(ER.get_loc (get_rep i)) + in + let typed_i = add_type_to_ident i i_type in + let%bind checked_stmts = type_stmts comp sts get_loc env in + pure + @@ add_stmt_to_stmts_env_gas + (TypedSyntax.Return typed_i, rep) + checked_stmts) | SendMsgs i -> let%bind r = fromR_TE @@ -943,7 +962,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~lc:(ER.get_loc (get_rep i)) in let typed_i = add_type_to_ident i i_type in - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.SendMsgs typed_i, rep) @@ -961,7 +980,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~lc:(ER.get_loc (get_rep i)) in let typed_i = add_type_to_ident i i_type in - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.CreateEvnt typed_i, rep) @@ -982,7 +1001,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~inst:(as_error_string p) (SR.get_loc (get_rep p))) in - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.CallProc (p, typed_args), rep) @@ -1002,7 +1021,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~actual:l_type.tp ~lc:(ER.get_loc (get_rep l)) in - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.Iterate (add_type_to_ident l l_type, p), rep) @@ -1014,7 +1033,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~inst:(as_error_string p) (SR.get_loc (get_rep p)))) | Throw iopt -> ( - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in match iopt with | Some i -> (* Same as CreateEvent. *) @@ -1040,17 +1059,17 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct (TypedSyntax.Throw None, rep) checked_stmts) | GasStmt g -> - let%bind checked_stmts = type_stmts sts get_loc env in + let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.GasStmt (type_gas_charge g), rep) checked_stmts) - and type_match_stmt_branch env styp ptrn sts get_loc = + and type_match_stmt_branch comp env styp ptrn sts get_loc = let%bind new_p, new_typings = assign_types_for_pattern styp ptrn in let%bind new_stmts, _ = with_extended_env env get_tenv_pure new_typings [] - (type_stmts sts get_loc) + (type_stmts comp sts get_loc) in pure @@ (new_p, new_stmts) @@ -1081,7 +1100,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct let append_params = CU.append_implicit_comp_params comp_params in let%bind typed_stmts, _ = with_extended_env env0 get_tenv_pure append_params [] - (type_stmts comp_body ER.get_loc) + (type_stmts tr comp_body ER.get_loc) in let new_proc_signatures = match comp_type with diff --git a/tests/checker/bad/Bad.ml b/tests/checker/bad/Bad.ml index 9cc1ec206..2e8f20dc2 100644 --- a/tests/checker/bad/Bad.ml +++ b/tests/checker/bad/Bad.ml @@ -100,6 +100,7 @@ module Tests = Scilla_test.Util.DiffBasedTests (struct "remote_read_bad_3.scilla"; "bad_cast_1.scilla"; "pm-error.scilla"; + "typecheck-return-1.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 1 diff --git a/tests/typecheck/contracts.t/run.t b/tests/typecheck/contracts.t/run.t new file mode 100644 index 000000000..a79d2a409 --- /dev/null +++ b/tests/typecheck/contracts.t/run.t @@ -0,0 +1,9 @@ + $ for f in *.scilla + > do + > scilla-checker -gaslimit 8000 -cf -libdir ../src/stdlib "$f" 2> CHECK-"$f" && + > diff CHECK-"$f" "$f".gold + > if [ $? -ne 0 ]; then + > break + > fi + > done + diff --git a/tests/typecheck/contracts.t/typecheck-return-1.scilla b/tests/typecheck/contracts.t/typecheck-return-1.scilla new file mode 100644 index 000000000..0cbc1f6ac --- /dev/null +++ b/tests/typecheck/contracts.t/typecheck-return-1.scilla @@ -0,0 +1,15 @@ +scilla_version 0 + +library TypecheckReturn1 + +contract TypecheckReturn1() + +procedure no_return() + a = _creation_block; + return a +end + +procedure incorrect_return_type() -> (String) + a = _creation_block; + return a +end diff --git a/tests/typecheck/contracts.t/typecheck-return-1.scilla.gold b/tests/typecheck/contracts.t/typecheck-return-1.scilla.gold new file mode 100644 index 000000000..dfe10c9b6 --- /dev/null +++ b/tests/typecheck/contracts.t/typecheck-return-1.scilla.gold @@ -0,0 +1,5 @@ + +tests/typecheck/contracts.t/typecheck-return-1.scilla:9:3: error: Procedure no_return cannot return because it doesn't have a return type +tests/typecheck/contracts.t/typecheck-return-1.scilla:14:10: error: Type unassignable: String expected, but BNum provided + +Gas remaining: 8000 From 3fa5d21a21a45722bc493d0666569fc3cfea8463 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 28 Oct 2022 16:05:02 +0700 Subject: [PATCH 05/41] fix(tests): Remove a redundant test --- tests/checker/bad/Bad.ml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/checker/bad/Bad.ml b/tests/checker/bad/Bad.ml index 2e8f20dc2..9cc1ec206 100644 --- a/tests/checker/bad/Bad.ml +++ b/tests/checker/bad/Bad.ml @@ -100,7 +100,6 @@ module Tests = Scilla_test.Util.DiffBasedTests (struct "remote_read_bad_3.scilla"; "bad_cast_1.scilla"; "pm-error.scilla"; - "typecheck-return-1.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 1 From 18dbf5f72027ab54820e7ce3f4187a127bc944d5 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 28 Oct 2022 16:08:43 +0700 Subject: [PATCH 06/41] fix(fmt): Correct return syntax w/o extra spaces --- src/formatter/ExtendedSyntax.ml | 29 +++++++++++-------- src/formatter/Formatter.ml | 11 +++++-- .../ast_does_not_change.t/return-1.scilla | 20 +++++++++++++ .../look_and_feel/return.t/return.scilla | 21 ++++++++++++++ tests/formatter/look_and_feel/return.t/run.t | 23 +++++++++++++++ 5 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 tests/formatter/ast_does_not_change.t/return-1.scilla create mode 100644 tests/formatter/look_and_feel/return.t/return.scilla create mode 100644 tests/formatter/look_and_feel/return.t/run.t diff --git a/src/formatter/ExtendedSyntax.ml b/src/formatter/ExtendedSyntax.ml index e0d752398..b4828d82d 100644 --- a/src/formatter/ExtendedSyntax.ml +++ b/src/formatter/ExtendedSyntax.ml @@ -123,6 +123,7 @@ struct comp_name : SR.rep id_ann; comp_params : (ER.rep id_ann * SType.t) list; comp_body : stmt_annot list; + comp_return : SType.t option; } [@@deriving sexp] @@ -720,20 +721,24 @@ struct in (import', import_as') - let extend_component tr comp = + let extend_component tr + Syn.{ comp_type; comp_name; comp_params; comp_body; comp_return } = let comp_comments = - let comp_name_loc = SR.get_loc (SIdentifier.get_rep comp.Syn.comp_name) in + let comp_name_loc = SR.get_loc (SIdentifier.get_rep comp_name) in collect_comments_above tr comp_name_loc - in - let comp_type = comp.Syn.comp_type in - let comp_name = extend_sr_id tr comp.comp_name in - let comp_params = - List.map comp.comp_params ~f:(fun (id, ty) -> (extend_er_id tr id, ty)) - in - let comp_body = - List.map comp.comp_body ~f:(fun stmt -> extend_stmt tr stmt) - in - { comp_comments; ExtSyn.comp_type; comp_name; comp_params; comp_body } + and comp_name = extend_sr_id tr comp_name + and comp_params = + List.map comp_params ~f:(fun (id, ty) -> (extend_er_id tr id, ty)) + and comp_body = List.map comp_body ~f:(fun stmt -> extend_stmt tr stmt) in + ExtSyn. + { + comp_comments; + comp_type; + comp_name; + comp_params; + comp_body; + comp_return; + } let extend_contract tr (contr : Syn.contract) : ExtSyn.contract = let cname = extend_sr_id tr contr.cname in diff --git a/src/formatter/Formatter.ml b/src/formatter/Formatter.ml index 9e7803ca9..8de6ffdea 100644 --- a/src/formatter/Formatter.ml +++ b/src/formatter/Formatter.ml @@ -456,13 +456,18 @@ struct typed_params) rparen - let of_component Ast.{comp_comments; comp_type; comp_name; comp_params; comp_body} = + let of_component Ast.{comp_comments; comp_type; comp_name; comp_params; comp_body; comp_return} = let comp_type = !^(Syntax.component_type_to_string comp_type) and comp_name = of_ann_id comp_name and comp_params = of_parameters comp_params ~sep:(break 1) and comp_body = of_stmts comp_body in - concat_comments comp_comments ^^ - group (comp_type ^^^ comp_name ^//^ comp_params) ^^ + let signature = match comp_return with + | None -> + (group (comp_type ^^^ comp_name ^//^ comp_params)) + | Some ty -> + (group (comp_type ^^^ comp_name ^//^ comp_params ^//^ arrow ^//^ of_type ty)) + in + concat_comments comp_comments ^^ signature ^^ indent (hardline ^^ comp_body) ^^ hardline ^^ end_kwd diff --git a/tests/formatter/ast_does_not_change.t/return-1.scilla b/tests/formatter/ast_does_not_change.t/return-1.scilla new file mode 100644 index 000000000..ae28bc0c6 --- /dev/null +++ b/tests/formatter/ast_does_not_change.t/return-1.scilla @@ -0,0 +1,20 @@ +scilla_version 0 + +library Return1 + +contract Return1() + +procedure no_return() + a = _creation_block; + return a +end + +procedure incorrect_return_type() -> (String) + a = _creation_block; + return a +end + +procedure return_1() -> BNum + a = _creation_block; + return a +end diff --git a/tests/formatter/look_and_feel/return.t/return.scilla b/tests/formatter/look_and_feel/return.t/return.scilla new file mode 100644 index 000000000..7ab7a8bff --- /dev/null +++ b/tests/formatter/look_and_feel/return.t/return.scilla @@ -0,0 +1,21 @@ +scilla_version 0 + +library Return + +contract Return() + +procedure no_return() + a = _creation_block; + return a +end + +procedure incorrect_return_type() -> (String) + a = _creation_block; + return a +end + +procedure return_1() -> BNum + a = _creation_block; + return a +end + diff --git a/tests/formatter/look_and_feel/return.t/run.t b/tests/formatter/look_and_feel/return.t/run.t new file mode 100644 index 000000000..2baf16b85 --- /dev/null +++ b/tests/formatter/look_and_feel/return.t/run.t @@ -0,0 +1,23 @@ + $ scilla-fmt return.scilla + scilla_version 0 + + library Return + + + contract Return () + + + procedure no_return () + a = _creation_block; + return a + end + + procedure incorrect_return_type () -> String + a = _creation_block; + return a + end + + procedure return_1 () -> BNum + a = _creation_block; + return a + end From 34a3ea2cbbd1cffe4130bd8cf3bdef43ebe04e52 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 28 Oct 2022 16:52:48 +0700 Subject: [PATCH 07/41] chore(parser): Update ParserFaults.messages --- src/base/ParserFaults.messages | 298 +++++++++++------- .../exp_t-emp-cid-underscore.scilexp.gold | 3 +- .../type_t-cid-map-cid-underscore.scilla.gold | 3 +- .../bad/gold/type_t-cid-tid-with.scilla.gold | 3 +- .../type_t-map-cid-cid-underscore.scilla.gold | 3 +- ...-lparen-map-cid-cid-underscore.scilla.gold | 6 +- ...-cid-lparen-map-cid-underscore.scilla.gold | 6 +- ...e_t-map-cid-map-cid-underscore.scilla.gold | 3 +- 8 files changed, 185 insertions(+), 140 deletions(-) diff --git a/src/base/ParserFaults.messages b/src/base/ParserFaults.messages index 59bb45aa7..ca18b1a80 100644 --- a/src/base/ParserFaults.messages +++ b/src/base/ParserFaults.messages @@ -1,6 +1,15 @@ #@ WARNING: #@ The following comment has been copied from "src/base/ParserFaults.messages". #@ It may need to be proofread, updated, moved, or removed. +#@ WARNING: +#@ The following comment has been copied from "src/base/ParserFaults.messages". +#@ It may need to be proofread, updated, moved, or removed. +#@ WARNING: +#@ The following comment has been copied from "src/base/ParserFaults.messages". +#@ It may need to be proofread, updated, moved, or removed. +#@ WARNING: +#@ The following comment has been copied from "src/base/ParserFaults.messages". +#@ It may need to be proofread, updated, moved, or removed. # This file is part of scilla. # # Copyright (c) 2018 - present Zilliqa Research Pvt. Ltd. @@ -31,7 +40,7 @@ type_term: CID LPAREN TID WITH ## ## Ends in an error in state: 74. ## -## targ -> LPAREN typ . RPAREN [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## targ -> LPAREN typ . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## typ -> typ . TARROW typ [ TARROW RPAREN ] ## ## The known suffix of the stack is as follows: @@ -45,7 +54,7 @@ type_term: CID LPAREN WITH ## ## Ends in an error in state: 73. ## -## targ -> LPAREN . typ RPAREN [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## targ -> LPAREN . typ RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -58,7 +67,7 @@ type_term: CID MAP WITH ## ## Ends in an error in state: 20. ## -## targ -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## targ -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -71,7 +80,7 @@ type_term: CID PERIOD WITH ## ## Ends in an error in state: 57. ## -## scid -> CID PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN ID HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## scid -> CID PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID PERIOD @@ -84,7 +93,7 @@ type_term: CID TID WITH ## ## Ends in an error in state: 77. ## -## list(targ) -> targ . list(targ) [ TARROW RPAREN RBRACE EQ EOF END COMMA ] +## list(targ) -> targ . list(targ) [ THROW TARROW SEND RPAREN RETURN RBRACE MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## targ @@ -97,8 +106,8 @@ type_term: FORALL TID PERIOD TID WITH ## ## Ends in an error in state: 69. ## -## typ -> typ . TARROW typ [ TARROW RPAREN EQ EOF END COMMA ] -## typ -> FORALL TID PERIOD typ . [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL TID PERIOD typ . [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID PERIOD typ @@ -111,7 +120,7 @@ type_term: FORALL TID PERIOD WITH ## ## Ends in an error in state: 68. ## -## typ -> FORALL TID PERIOD . typ [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> FORALL TID PERIOD . typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID PERIOD @@ -124,7 +133,7 @@ type_term: FORALL TID WITH ## ## Ends in an error in state: 67. ## -## typ -> FORALL TID . PERIOD typ [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> FORALL TID . PERIOD typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID @@ -137,7 +146,7 @@ type_term: FORALL WITH ## ## Ends in an error in state: 66. ## -## typ -> FORALL . TID PERIOD typ [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> FORALL . TID PERIOD typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL @@ -151,7 +160,7 @@ type_term: LPAREN TID WITH ## Ends in an error in state: 82. ## ## typ -> typ . TARROW typ [ TARROW RPAREN ] -## typ -> LPAREN typ . RPAREN [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> LPAREN typ . RPAREN [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN typ @@ -164,7 +173,7 @@ type_term: LPAREN WITH ## ## Ends in an error in state: 65. ## -## typ -> LPAREN . typ RPAREN [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> LPAREN . typ RPAREN [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -192,7 +201,7 @@ type_term: MAP CID LPAREN MAP WITH ## ## Ends in an error in state: 39. ## -## t_map_value -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## t_map_value -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -205,7 +214,7 @@ type_term: MAP CID LPAREN WITH ## ## Ends in an error in state: 41. ## -## t_map_value -> LPAREN . t_map_value_allow_targs RPAREN [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## t_map_value -> LPAREN . t_map_value_allow_targs RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -218,13 +227,13 @@ type_term: MAP CID UNDERSCORE ## ## Ends in an error in state: 25. ## -## address_typ -> CID . WITH END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID . WITH LIBRARY END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID . WITH SPID END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID . WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## scid -> CID . [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## scid -> CID . PERIOD CID [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## address_typ -> CID . WITH END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID . [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID . PERIOD CID [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID @@ -251,7 +260,7 @@ type_term: MAP WITH ## ## Ends in an error in state: 37. ## -## typ -> MAP . t_map_key t_map_value [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> MAP . t_map_key t_map_value [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -264,8 +273,8 @@ type_term: TID TARROW TID WITH ## ## Ends in an error in state: 71. ## -## typ -> typ . TARROW typ [ TARROW RPAREN EQ EOF END COMMA ] -## typ -> typ TARROW typ . [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ TARROW typ . [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## typ TARROW typ @@ -278,7 +287,7 @@ type_term: TID TARROW WITH ## ## Ends in an error in state: 70. ## -## typ -> typ TARROW . typ [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> typ TARROW . typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## typ TARROW @@ -291,11 +300,11 @@ type_term: CID WITH EOF ## ## Ends in an error in state: 26. ## -## address_typ -> CID WITH . END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID WITH . CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID WITH . LIBRARY END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID WITH . SPID END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID WITH . CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## address_typ -> CID WITH . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH @@ -306,7 +315,7 @@ Invalid or incomplete type. type_term: TID WITH ## -## Ends in an error in state: 370. +## Ends in an error in state: 375. ## ## typ -> typ . TARROW typ [ TARROW EOF ] ## type_term -> typ . EOF [ # ] @@ -320,7 +329,7 @@ This is an invalid type term, the ADT constructor arguments are likely incorrect type_term: WITH ## -## Ends in an error in state: 368. +## Ends in an error in state: 373. ## ## type_term' -> . type_term [ # ] ## @@ -333,7 +342,7 @@ This is an invalid type term. stmts_term: ACCEPT WITH ## -## Ends in an error in state: 320. +## Ends in an error in state: 321. ## ## separated_nonempty_list(SEMICOLON,stmt) -> stmt . [ EOF END BAR ] ## separated_nonempty_list(SEMICOLON,stmt) -> stmt . SEMICOLON separated_nonempty_list(SEMICOLON,stmt) [ EOF END BAR ] @@ -348,7 +357,7 @@ This is likely an improperly terminated statement (lacking the semicolon). stmts_term: CID WITH ## -## Ends in an error in state: 324. +## Ends in an error in state: 325. ## ## stmt -> component_id . list(sident) [ SEMICOLON EOF END BAR ] ## @@ -361,7 +370,7 @@ This is an invalid statements term. stmts_term: DELETE ID WITH ## -## Ends in an error in state: 317. +## Ends in an error in state: 318. ## ## stmt -> DELETE ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -374,7 +383,7 @@ This is an invalid delete statement, it lacks the keys to delete. stmts_term: DELETE WITH ## -## Ends in an error in state: 316. +## Ends in an error in state: 317. ## ## stmt -> DELETE . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -387,7 +396,7 @@ This is an invalid delete statement, it lacks a map to delete from. stmts_term: EVENT WITH ## -## Ends in an error in state: 314. +## Ends in an error in state: 315. ## ## stmt -> EVENT . sid [ SEMICOLON EOF END BAR ] ## @@ -400,7 +409,7 @@ This is an invalid event statement, it lacks a separated identifier for the even stmts_term: ID ASSIGN WITH ## -## Ends in an error in state: 306. +## Ends in an error in state: 307. ## ## stmt -> ID ASSIGN . sid [ SEMICOLON EOF END BAR ] ## @@ -413,7 +422,7 @@ This is an invalid assign statement, it lacks a separated identifier. stmts_term: ID FETCH AND WITH ## -## Ends in an error in state: 272. +## Ends in an error in state: 274. ## ## remote_fetch_stmt -> ID FETCH AND . ID PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND . SPID PERIOD SPID [ SEMICOLON EOF END BAR ] @@ -432,7 +441,7 @@ This is an invalid bind and statement. The parser expects a capital identifier a stmts_term: ID FETCH EXISTS ID WITH ## -## Ends in an error in state: 270. +## Ends in an error in state: 272. ## ## stmt -> ID FETCH EXISTS ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -445,7 +454,7 @@ This is an invalid existence bind statement. It lacks a non-empty list of access stmts_term: ID FETCH EXISTS WITH ## -## Ends in an error in state: 269. +## Ends in an error in state: 271. ## ## stmt -> ID FETCH EXISTS . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -458,7 +467,7 @@ This is an invalid existence bind statement. It lacks a map to check existence o stmts_term: ID FETCH ID WITH ## -## Ends in an error in state: 265. +## Ends in an error in state: 267. ## ## sid -> ID . [ SEMICOLON EOF END BAR ] ## stmt -> ID FETCH ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] @@ -472,7 +481,7 @@ This is an invalid bind statement, it is lacking a non empty list of map accesse stmts_term: ID FETCH WITH ## -## Ends in an error in state: 264. +## Ends in an error in state: 266. ## ## remote_fetch_stmt -> ID FETCH . AND ID PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH . AND SPID PERIOD SPID [ SEMICOLON EOF END BAR ] @@ -494,7 +503,7 @@ This is an invalid bind statement, the bind can be followed by '&', 'exists' or stmts_term: ID EQ WITH ## -## Ends in an error in state: 304. +## Ends in an error in state: 305. ## ## stmt -> ID EQ . exp [ SEMICOLON EOF END BAR ] ## @@ -507,7 +516,7 @@ This is an invalid equal statement, it is lacking a valid expression on the righ stmts_term: ID LSQB SPID RSQB ASSIGN WITH ## -## Ends in an error in state: 309. +## Ends in an error in state: 310. ## ## stmt -> ID nonempty_list(map_access) ASSIGN . sid [ SEMICOLON EOF END BAR ] ## @@ -520,7 +529,7 @@ The map key must be assigned to some separated identifier. stmts_term: ID LSQB SPID RSQB SEMICOLON ## -## Ends in an error in state: 308. +## Ends in an error in state: 309. ## ## stmt -> ID nonempty_list(map_access) . ASSIGN sid [ SEMICOLON EOF END BAR ] ## @@ -531,7 +540,7 @@ stmts_term: ID LSQB SPID RSQB SEMICOLON ## This implies that, although the LR(1) items shown above provide an ## accurate view of the past (what has been recognized so far), they ## may provide an INCOMPLETE view of the future (what was expected next). -## In state 267, spurious reduction of production nonempty_list(map_access) -> map_access +## In state 269, spurious reduction of production nonempty_list(map_access) -> map_access ## # see tests/parser/bad/stmts_t-id-lsqb-spid-rsqb-semicolon.scilla @@ -539,7 +548,7 @@ This is likely an invalid map assign statement, it lacks the assign. stmts_term: ID LSQB SPID RSQB WITH ## -## Ends in an error in state: 267. +## Ends in an error in state: 269. ## ## nonempty_list(map_access) -> map_access . [ SEMICOLON EOF END BAR ASSIGN ] ## nonempty_list(map_access) -> map_access . nonempty_list(map_access) [ SEMICOLON EOF END BAR ASSIGN ] @@ -553,7 +562,7 @@ This is an invalid statements term. A possible continuation may be assigning a m stmts_term: ID LSQB SPID WITH ## -## Ends in an error in state: 262. +## Ends in an error in state: 264. ## ## map_access -> LSQB sident . RSQB [ SEMICOLON LSQB EOF END BAR ASSIGN ] ## @@ -566,7 +575,7 @@ This is an invalid statements term. A possible continuation may be accessing a k stmts_term: ID LSQB WITH ## -## Ends in an error in state: 261. +## Ends in an error in state: 263. ## ## map_access -> LSQB . sident RSQB [ SEMICOLON LSQB EOF END BAR ASSIGN ] ## @@ -592,7 +601,7 @@ This is an invalid statements term, likely a bad procedure call with faulty argu stmts_term: ID WITH ## -## Ends in an error in state: 260. +## Ends in an error in state: 262. ## ## component_id -> ID . [ SPID SEMICOLON ID EOF END CID BAR ] ## remote_fetch_stmt -> ID . FETCH AND ID PERIOD sident [ SEMICOLON EOF END BAR ] @@ -618,7 +627,7 @@ This is an invalid statements term. Scilla expects to do something with the iden stmts_term: MATCH SPID UNDERSCORE ## -## Ends in an error in state: 255. +## Ends in an error in state: 257. ## ## stmt -> MATCH sid . WITH list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -631,7 +640,7 @@ This is an invalid match statement, 'with' is expected after what is specified t stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW ACCEPT EOF ## -## Ends in an error in state: 328. +## Ends in an error in state: 329. ## ## list(stmt_pm_clause) -> stmt_pm_clause . list(stmt_pm_clause) [ END ] ## @@ -642,9 +651,9 @@ stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW ACCEPT EOF ## This implies that, although the LR(1) items shown above provide an ## accurate view of the past (what has been recognized so far), they ## may provide an INCOMPLETE view of the future (what was expected next). -## In state 320, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 326, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 327, spurious reduction of production stmt_pm_clause -> BAR pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 321, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 327, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 328, spurious reduction of production stmt_pm_clause -> BAR pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) ## # see tests/parser/bad/stmts_t-match-spid-with-bar-underscore-arrow-accept-eof.scilla @@ -652,7 +661,7 @@ When the match statement is finished, the parser expects 'end'. stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW WITH ## -## Ends in an error in state: 259. +## Ends in an error in state: 261. ## ## stmt_pm_clause -> BAR pattern ARROW . loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -665,7 +674,7 @@ This is an invalid statements term. In the match expression, after an arrow the stmts_term: MATCH SPID WITH BAR UNDERSCORE WITH ## -## Ends in an error in state: 258. +## Ends in an error in state: 260. ## ## stmt_pm_clause -> BAR pattern . ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -678,7 +687,7 @@ This is an invalid statements term. In the match expression, after a pattern is stmts_term: MATCH SPID WITH BAR WITH ## -## Ends in an error in state: 257. +## Ends in an error in state: 259. ## ## stmt_pm_clause -> BAR . pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -691,7 +700,7 @@ In the match statement there is a malformed pattern. stmts_term: MATCH SPID WITH WITH ## -## Ends in an error in state: 256. +## Ends in an error in state: 258. ## ## stmt -> MATCH sid WITH . list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -704,7 +713,7 @@ There is a malformed pattern matching clause, the bar is likely missing. stmts_term: MATCH WITH ## -## Ends in an error in state: 254. +## Ends in an error in state: 256. ## ## stmt -> MATCH . sid WITH list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -756,7 +765,7 @@ It is expected to send to a separated identifier. stmts_term: THROW END ## -## Ends in an error in state: 366. +## Ends in an error in state: 371. ## ## stmts_term -> stmts . EOF [ # ] ## @@ -769,9 +778,9 @@ stmts_term: THROW END ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 249, spurious reduction of production option(sid) -> ## In state 251, spurious reduction of production stmt -> THROW option(sid) -## In state 320, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 326, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 334, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 321, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 327, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 335, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) ## # special case, only via stmts_term entry point should never happen # throw itself is a valid statement term and a procedure or transition @@ -781,7 +790,7 @@ This is an invalid statements term, bad throw. stmts_term: THROW SEMICOLON WITH ## -## Ends in an error in state: 321. +## Ends in an error in state: 322. ## ## separated_nonempty_list(SEMICOLON,stmt) -> stmt SEMICOLON . separated_nonempty_list(SEMICOLON,stmt) [ EOF END BAR ] ## @@ -809,7 +818,7 @@ This throw does not throw a valid exception or is not properly terminated. stmts_term: WITH ## -## Ends in an error in state: 364. +## Ends in an error in state: 369. ## ## stmts_term' -> . stmts_term [ # ] ## @@ -862,7 +871,7 @@ To import another library mention the new library name directly after the previo lmodule: SCILLA_VERSION NUMLIT IMPORT CONTRACT ## -## Ends in an error in state: 360. +## Ends in an error in state: 365. ## ## lmodule -> SCILLA_VERSION NUMLIT imports . library EOF [ # ] ## @@ -895,7 +904,7 @@ If import is mentioned there must be one or more imported libraries with capital lmodule: SCILLA_VERSION NUMLIT LIBRARY CID CONTRACT ## -## Ends in an error in state: 361. +## Ends in an error in state: 366. ## ## lmodule -> SCILLA_VERSION NUMLIT imports library . EOF [ # ] ## @@ -1114,7 +1123,7 @@ This is an invalid library module because it lacks a capital identifier for a na lmodule: SCILLA_VERSION NUMLIT WITH ## -## Ends in an error in state: 359. +## Ends in an error in state: 364. ## ## lmodule -> SCILLA_VERSION NUMLIT . imports library EOF [ # ] ## @@ -1127,7 +1136,7 @@ This is an invalid library module, Scilla version must be followed by 'library' lmodule: WITH ## -## Ends in an error in state: 357. +## Ends in an error in state: 362. ## ## lmodule' -> . lmodule [ # ] ## @@ -1737,7 +1746,7 @@ This is an invalid expression. If it is an application of a function, it is nece exp_term: STRING WITH ## -## Ends in an error in state: 355. +## Ends in an error in state: 360. ## ## exp_term -> exp . EOF [ # ] ## @@ -1789,7 +1798,7 @@ Type functions expect a type id (e.g. 'A). exp_term: WITH ## -## Ends in an error in state: 353. +## Ends in an error in state: 358. ## ## exp_term' -> . exp_term [ # ] ## @@ -1830,9 +1839,9 @@ For a mutable field declaration, the parser expects a valid lower case beginning cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE ID LPAREN RPAREN WITH ## -## Ends in an error in state: 338. +## Ends in an error in state: 339. ## -## procedure -> PROCEDURE component_id component_params . component_body [ TRANSITION PROCEDURE EOF ] +## procedure -> PROCEDURE component_id component_params . option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## ## The known suffix of the stack is as follows: ## PROCEDURE component_id component_params @@ -1843,9 +1852,9 @@ In the transition body the parser expects a list of semi-colon separated stateme cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE ID WITH ## -## Ends in an error in state: 337. +## Ends in an error in state: 338. ## -## procedure -> PROCEDURE component_id . component_params component_body [ TRANSITION PROCEDURE EOF ] +## procedure -> PROCEDURE component_id . component_params option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## ## The known suffix of the stack is as follows: ## PROCEDURE component_id @@ -1857,9 +1866,9 @@ be a left parenthesis. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE WITH ## -## Ends in an error in state: 336. +## Ends in an error in state: 337. ## -## procedure -> PROCEDURE . component_id component_params component_body [ TRANSITION PROCEDURE EOF ] +## procedure -> PROCEDURE . component_id component_params option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## ## The known suffix of the stack is as follows: ## PROCEDURE @@ -1870,7 +1879,7 @@ A procedure requires a valid name. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN RPAREN END WITH ## -## Ends in an error in state: 343. +## Ends in an error in state: 348. ## ## list(component) -> component . list(component) [ EOF ] ## @@ -1883,7 +1892,7 @@ Following a transition definition, the parser expects a transition or a procedur cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN RPAREN THROW BAR ## -## Ends in an error in state: 332. +## Ends in an error in state: 333. ## ## component_body -> stmts . END [ TRANSITION PROCEDURE EOF ] ## @@ -1896,9 +1905,9 @@ cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN R ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 249, spurious reduction of production option(sid) -> ## In state 251, spurious reduction of production stmt -> THROW option(sid) -## In state 320, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 326, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 334, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 321, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 327, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 335, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) ## # see tests/parser/cmodule-transition-id-lparen-rparen-throw-bar.scilla @@ -1921,7 +1930,7 @@ cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN W ## ## Ends in an error in state: 245. ## -## component_params -> LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN [ THROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## component_params -> LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN [ THROW TARROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -2029,7 +2038,7 @@ cmodule: SCILLA_VERSION NUMLIT LIBRARY CID EOF ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 12, spurious reduction of production list(libentry) -> ## In state 223, spurious reduction of production library -> LIBRARY CID list(libentry) -## In state 351, spurious reduction of production option(library) -> library +## In state 356, spurious reduction of production option(library) -> library ## # see tests/parser/bad/cmodule-version-number-library-name @@ -2117,7 +2126,7 @@ type_term: CID MAP CID TYPE ## ## Ends in an error in state: 107. ## -## targ -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## targ -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2136,7 +2145,7 @@ type_term: CID TYPE ## ## Ends in an error in state: 72. ## -## typ -> scid . list(targ) [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> scid . list(targ) [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## scid @@ -2220,7 +2229,7 @@ type_term: CID WITH CONTRACT LPAREN RPAREN WITH ## ## Ends in an error in state: 92. ## -## address_typ -> CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## address_typ -> CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN @@ -2232,7 +2241,7 @@ type_term: CID WITH CONTRACT LPAREN WITH ## ## Ends in an error in state: 33. ## -## address_typ -> CID WITH CONTRACT LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## address_typ -> CID WITH CONTRACT LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT LPAREN @@ -2244,8 +2253,8 @@ type_term: CID WITH CONTRACT WITH ## ## Ends in an error in state: 32. ## -## address_typ -> CID WITH CONTRACT . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] -## address_typ -> CID WITH CONTRACT . LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## address_typ -> CID WITH CONTRACT . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT . LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT @@ -2257,7 +2266,7 @@ type_term: HEXLIT WITH ## ## Ends in an error in state: 22. ## -## scid -> HEXLIT . PERIOD CID [ UNDERSCORE TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN ID HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## scid -> HEXLIT . PERIOD CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## HEXLIT @@ -2269,7 +2278,7 @@ type_term: MAP CID MAP CID TYPE ## ## Ends in an error in state: 40. ## -## t_map_value -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## t_map_value -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2288,7 +2297,7 @@ type_term: MAP CID TYPE ## ## Ends in an error in state: 38. ## -## typ -> MAP t_map_key . t_map_value [ TARROW RPAREN EQ EOF END COMMA ] +## typ -> MAP t_map_key . t_map_value [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2335,7 +2344,7 @@ Ends in an error in state: 99. stmts_term: FORALL SPID WITH ## -## Ends in an error in state: 312. +## Ends in an error in state: 313. ## ## stmt -> FORALL sident . component_id [ SEMICOLON EOF END BAR ] ## @@ -2347,7 +2356,7 @@ Ends in an error in state: 297. stmts_term: FORALL WITH ## -## Ends in an error in state: 311. +## Ends in an error in state: 312. ## ## stmt -> FORALL . sident component_id [ SEMICOLON EOF END BAR ] ## @@ -2359,7 +2368,7 @@ Ends in an error in state: 296. stmts_term: ID FETCH AND CID PERIOD ID WITH ## -## Ends in an error in state: 299. +## Ends in an error in state: 300. ## ## remote_fetch_stmt -> ID FETCH AND sident . AS address_typ [ SEMICOLON EOF END BAR ] ## @@ -2371,7 +2380,7 @@ Remote reads are not allowed to use namespaces. stmts_term: ID FETCH AND CID WITH ## -## Ends in an error in state: 289. +## Ends in an error in state: 291. ## ## sident -> CID . PERIOD ID [ AS ] ## stmt -> ID FETCH AND CID . option(bcfetch_args) [ SEMICOLON EOF END BAR ] @@ -2384,7 +2393,7 @@ Ends in an error in state: 283. stmts_term: ID FETCH AND EXISTS ID PERIOD ID WITH ## -## Ends in an error in state: 287. +## Ends in an error in state: 289. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID PERIOD ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2396,7 +2405,7 @@ Ends in an error in state: 281. stmts_term: ID FETCH AND EXISTS ID PERIOD WITH ## -## Ends in an error in state: 286. +## Ends in an error in state: 288. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID PERIOD . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2408,7 +2417,7 @@ Ends in an error in state: 280. stmts_term: ID FETCH AND EXISTS ID WITH ## -## Ends in an error in state: 285. +## Ends in an error in state: 287. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID . PERIOD ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2420,7 +2429,7 @@ Ends in an error in state: 279. stmts_term: ID FETCH AND EXISTS WITH ## -## Ends in an error in state: 284. +## Ends in an error in state: 286. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS . ID PERIOD ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2432,7 +2441,7 @@ Ends in an error in state: 278. stmts_term: ID FETCH AND ID PERIOD ID WITH ## -## Ends in an error in state: 281. +## Ends in an error in state: 283. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## sident -> ID . [ SEMICOLON EOF END BAR ] @@ -2445,7 +2454,7 @@ Ends in an error in state: 275. stmts_term: ID FETCH AND ID PERIOD LPAREN SPID WITH ## -## Ends in an error in state: 279. +## Ends in an error in state: 281. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD LPAREN sident . RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2457,7 +2466,7 @@ Ends in an error in state: 273. stmts_term: ID FETCH AND ID PERIOD LPAREN WITH ## -## Ends in an error in state: 278. +## Ends in an error in state: 280. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD LPAREN . sident RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2469,7 +2478,7 @@ Ends in an error in state: 272. stmts_term: ID FETCH AND ID PERIOD WITH ## -## Ends in an error in state: 277. +## Ends in an error in state: 279. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD . sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND ID PERIOD . LPAREN sident RPAREN [ SEMICOLON EOF END BAR ] @@ -2483,7 +2492,7 @@ Ends in an error in state: 271. stmts_term: ID FETCH AND ID WITH ## -## Ends in an error in state: 276. +## Ends in an error in state: 278. ## ## remote_fetch_stmt -> ID FETCH AND ID . PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND ID . PERIOD LPAREN sident RPAREN [ SEMICOLON EOF END BAR ] @@ -2498,7 +2507,7 @@ Either blockchain state variable or remote field read expected. stmts_term: ID FETCH AND SPID AS CID UNDERSCORE ## -## Ends in an error in state: 301. +## Ends in an error in state: 302. ## ## address_typ -> CID . WITH END [ SEMICOLON EOF END BAR ] ## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ SEMICOLON EOF END BAR ] @@ -2514,7 +2523,7 @@ Casts to non-ByStr20 types are not allowed. stmts_term: ID FETCH AND SPID AS WITH ## -## Ends in an error in state: 300. +## Ends in an error in state: 301. ## ## remote_fetch_stmt -> ID FETCH AND sident AS . address_typ [ SEMICOLON EOF END BAR ] ## @@ -2526,7 +2535,7 @@ Ends in an error in state: 285. stmts_term: ID FETCH AND SPID PERIOD WITH ## -## Ends in an error in state: 274. +## Ends in an error in state: 276. ## ## remote_fetch_stmt -> ID FETCH AND SPID PERIOD . SPID [ SEMICOLON EOF END BAR ] ## @@ -2538,7 +2547,7 @@ Ends in an error in state: 268. stmts_term: ID FETCH AND SPID WITH ## -## Ends in an error in state: 273. +## Ends in an error in state: 275. ## ## remote_fetch_stmt -> ID FETCH AND SPID . PERIOD SPID [ SEMICOLON EOF END BAR ] ## sident -> SPID . [ AS ] @@ -2551,7 +2560,7 @@ Ends in an error in state: 267. lmodule: SCILLA_VERSION WITH ## -## Ends in an error in state: 358. +## Ends in an error in state: 363. ## ## lmodule -> SCILLA_VERSION . NUMLIT imports library EOF [ # ] ## @@ -2615,7 +2624,7 @@ exp_term: HEXLIT PERIOD WITH ## ## Ends in an error in state: 23. ## -## scid -> HEXLIT PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID TARROW SPID SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET LBRACE IN ID HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## scid -> HEXLIT PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET LBRACE IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## HEXLIT PERIOD @@ -2658,7 +2667,7 @@ match-expression is probably missing `end` keyword. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN FIELD ID COLON TID EQ STRING WITH ## -## Ends in an error in state: 345. +## Ends in an error in state: 350. ## ## list(field) -> field . list(field) [ TRANSITION PROCEDURE EOF ] ## @@ -2881,7 +2890,7 @@ type_term: MAP CID LPAREN MAP CID CID TYPE ## ## Ends in an error in state: 42. ## -## t_map_value -> LPAREN t_map_value_allow_targs . RPAREN [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## t_map_value -> LPAREN t_map_value_allow_targs . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN t_map_value_allow_targs @@ -2922,7 +2931,7 @@ type_term: CID WITH SPID WITH ## ## Ends in an error in state: 27. ## -## address_typ -> CID WITH SPID . END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## address_typ -> CID WITH SPID . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH SPID @@ -2934,7 +2943,7 @@ type_term: CID WITH LIBRARY WITH ## ## Ends in an error in state: 29. ## -## address_typ -> CID WITH LIBRARY . END [ TYPE TRANSITION TID TARROW SEMICOLON RPAREN RBRACE PROCEDURE MAP LPAREN LET IN HEXLIT FIELD EQ EOF END CONTRACT COMMA CID BAR ARROW ] +## address_typ -> CID WITH LIBRARY . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH LIBRARY @@ -2944,9 +2953,9 @@ Ends in an error in state: 29. Please report your example at https://github.com/ stmts_term: ID FETCH AND CID LPAREN WITH ## -## Ends in an error in state: 290. +## Ends in an error in state: 292. ## -## bcfetch_args -> LPAREN . loption(separated_nonempty_list(COMMA,sident)) RPAREN [ SEMICOLON EOF END BAR ] +## bcfetch_args -> LPAREN . separated_nonempty_list(COMMA,sident) RPAREN [ SEMICOLON EOF END BAR ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -2956,7 +2965,7 @@ Ends in an error in state: 290. Please report your example at https://github.com stmts_term: ID FETCH AND CID LPAREN ID WITH ## -## Ends in an error in state: 291. +## Ends in an error in state: 293. ## ## separated_nonempty_list(COMMA,sident) -> sident . [ RPAREN ] ## separated_nonempty_list(COMMA,sident) -> sident . COMMA separated_nonempty_list(COMMA,sident) [ RPAREN ] @@ -2969,7 +2978,7 @@ Ends in an error in state: 291. Please report your example at https://github.com stmts_term: ID FETCH AND CID LPAREN ID COMMA WITH ## -## Ends in an error in state: 292. +## Ends in an error in state: 294. ## ## separated_nonempty_list(COMMA,sident) -> sident COMMA . separated_nonempty_list(COMMA,sident) [ RPAREN ] ## @@ -2978,3 +2987,48 @@ stmts_term: ID FETCH AND CID LPAREN ID COMMA WITH ## Ends in an error in state: 292. Please report your example at https://github.com/Zilliqa/scilla/issues. + +stmts_term: RETURN WITH +## +## Ends in an error in state: 254. +## +## stmt -> RETURN . sid [ SEMICOLON EOF END BAR ] +## +## The known suffix of the stack is as follows: +## RETURN +## + + + +cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN TARROW WITH +## +## Ends in an error in state: 340. +## +## return_type -> TARROW . typ [ THROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## +## The known suffix of the stack is as follows: +## TARROW +## + + + +cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN TARROW CID RPAREN +## +## Ends in an error in state: 341. +## +## return_type -> TARROW typ . [ THROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## typ -> typ . TARROW typ [ THROW TARROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## +## The known suffix of the stack is as follows: +## TARROW typ +## +## WARNING: This example involves spurious reductions. +## This implies that, although the LR(1) items shown above provide an +## accurate view of the past (what has been recognized so far), they +## may provide an INCOMPLETE view of the future (what was expected next). +## In state 25, spurious reduction of production scid -> CID +## In state 72, spurious reduction of production list(targ) -> +## In state 81, spurious reduction of production typ -> scid list(targ) +## + + diff --git a/tests/base/parser/bad/gold/exp_t-emp-cid-underscore.scilexp.gold b/tests/base/parser/bad/gold/exp_t-emp-cid-underscore.scilexp.gold index b826ce924..1fe62b294 100644 --- a/tests/base/parser/bad/gold/exp_t-emp-cid-underscore.scilexp.gold +++ b/tests/base/parser/bad/gold/exp_t-emp-cid-underscore.scilexp.gold @@ -1,8 +1,7 @@ { "errors": [ { - "error_message": - "This map type likely has an invalid map value type.\n", + "error_message": "Ends in an error in state: 147.\n", "start_location": { "file": "base/parser/bad/exps/exp_t-emp-cid-underscore.scilexp", "line": 1, diff --git a/tests/base/parser/bad/gold/type_t-cid-map-cid-underscore.scilla.gold b/tests/base/parser/bad/gold/type_t-cid-map-cid-underscore.scilla.gold index 4bb76f3ec..7183901c1 100644 --- a/tests/base/parser/bad/gold/type_t-cid-map-cid-underscore.scilla.gold +++ b/tests/base/parser/bad/gold/type_t-cid-map-cid-underscore.scilla.gold @@ -1,8 +1,7 @@ { "errors": [ { - "error_message": - "This map type likely has an invalid map value type.\n", + "error_message": "Ends in an error in state: 101.\n", "start_location": { "file": "base/parser/bad/type_t-cid-map-cid-underscore.scilla", "line": 6, diff --git a/tests/base/parser/bad/gold/type_t-cid-tid-with.scilla.gold b/tests/base/parser/bad/gold/type_t-cid-tid-with.scilla.gold index a649bd367..94dce17b4 100644 --- a/tests/base/parser/bad/gold/type_t-cid-tid-with.scilla.gold +++ b/tests/base/parser/bad/gold/type_t-cid-tid-with.scilla.gold @@ -1,8 +1,7 @@ { "errors": [ { - "error_message": - "This is an invalid type term, the ADT constructor arguments are incorrect.\n", + "error_message": "This type annotation is not closed properly, or is missing parentheses to group the types, or has a missing or misplaced '='.\n", "start_location": { "file": "base/parser/bad/type_t-cid-tid-with.scilla", "line": 6, diff --git a/tests/base/parser/bad/gold/type_t-map-cid-cid-underscore.scilla.gold b/tests/base/parser/bad/gold/type_t-map-cid-cid-underscore.scilla.gold index 0342303e3..cce7de815 100644 --- a/tests/base/parser/bad/gold/type_t-map-cid-cid-underscore.scilla.gold +++ b/tests/base/parser/bad/gold/type_t-map-cid-cid-underscore.scilla.gold @@ -1,8 +1,7 @@ { "errors": [ { - "error_message": - "This map type likely has an invalid map value type.\n", + "error_message": "This type annotation is not closed properly, or is missing parentheses to group the types, or has a missing or misplaced '='.\n", "start_location": { "file": "base/parser/bad/type_t-map-cid-cid-underscore.scilla", "line": 5, diff --git a/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-cid-underscore.scilla.gold b/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-cid-underscore.scilla.gold index 5ac2eee74..cebdba5f6 100644 --- a/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-cid-underscore.scilla.gold +++ b/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-cid-underscore.scilla.gold @@ -1,11 +1,9 @@ { "errors": [ { - "error_message": - "This map type likely has an invalid map value type.\n", + "error_message": "This is an invalid map type, the map value type is likely incorrect. The map type must be a storable type, i.e., a base type, a valid ADT, or a map type.\n", "start_location": { - "file": - "base/parser/bad/type_t-map-cid-lparen-map-cid-cid-underscore.scilla", + "file": "base/parser/bad/type_t-map-cid-lparen-map-cid-cid-underscore.scilla", "line": 4, "column": 50 }, diff --git a/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-underscore.scilla.gold b/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-underscore.scilla.gold index 66fb5f970..0fd088b35 100644 --- a/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-underscore.scilla.gold +++ b/tests/base/parser/bad/gold/type_t-map-cid-lparen-map-cid-underscore.scilla.gold @@ -1,11 +1,9 @@ { "errors": [ { - "error_message": - "This map type likely has an invalid map value type.\n", + "error_message": "Ends in an error in state: 36.\n", "start_location": { - "file": - "base/parser/bad/type_t-map-cid-lparen-map-cid-underscore.scilla", + "file": "base/parser/bad/type_t-map-cid-lparen-map-cid-underscore.scilla", "line": 5, "column": 40 }, diff --git a/tests/base/parser/bad/gold/type_t-map-cid-map-cid-underscore.scilla.gold b/tests/base/parser/bad/gold/type_t-map-cid-map-cid-underscore.scilla.gold index 476462a77..f10613efc 100644 --- a/tests/base/parser/bad/gold/type_t-map-cid-map-cid-underscore.scilla.gold +++ b/tests/base/parser/bad/gold/type_t-map-cid-map-cid-underscore.scilla.gold @@ -1,8 +1,7 @@ { "errors": [ { - "error_message": - "This map type likely has an invalid map value type.\n", + "error_message": "Ends in an error in state: 36.\n", "start_location": { "file": "base/parser/bad/type_t-map-cid-map-cid-underscore.scilla", "line": 7, From 172e45dc6926d1728244d0d10825bfaedbe5e8a7 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 28 Oct 2022 16:53:09 +0700 Subject: [PATCH 08/41] chore(makefile): Fix a typo. NFC. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 57357459e..e5cdc6431 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ parser-messages: mv src/base/NewParserFaults.messages src/base/ParserFaults.messages rm src/base/NewParserFaultsStubs.messages -# Launch utop such that it finds the libraroes. +# Launch utop such that it finds the libraries. utop: release OCAMLPATH=_build/install/default/lib:$(OCAMLPATH) utop From 99dd69731714bc7ccadb149b3cfc73b8c5989aca Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sat, 5 Nov 2022 18:45:39 +0700 Subject: [PATCH 09/41] wip --- .gitignore | 2 ++ src/base/ParserUtil.ml | 5 ++++- src/base/Syntax.ml | 7 +++++-- src/eval/Eval.ml | 4 ++-- src/eval/EvalUtil.ml | 5 +++++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 9f23387f8..a9086b720 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,5 @@ deps/cryptoutils/install/ deps/schnorr/build/ deps/schnorr/install/ +vcpkg_installed +tags diff --git a/src/base/ParserUtil.ml b/src/base/ParserUtil.ml index 528d94af3..e17491e29 100644 --- a/src/base/ParserUtil.ml +++ b/src/base/ParserUtil.ml @@ -139,7 +139,10 @@ module type Syn = sig | Iterate of ParserRep.rep SIdentifier.t * ParserRep.rep SIdentifier.t | SendMsgs of ParserRep.rep SIdentifier.t | CreateEvnt of ParserRep.rep SIdentifier.t - | CallProc of ParserRep.rep SIdentifier.t * ParserRep.rep SIdentifier.t list + | CallProc of + ParserRep.rep SIdentifier.t + * ParserRep.rep SIdentifier.t + * ParserRep.rep SIdentifier.t list | Throw of ParserRep.rep SIdentifier.t option | GasStmt of SGasCharge.gas_charge diff --git a/src/base/Syntax.ml b/src/base/Syntax.ml index 9dd7f4a9d..22c3f0b57 100644 --- a/src/base/Syntax.ml +++ b/src/base/Syntax.ml @@ -369,8 +369,11 @@ module ScillaSyntax (SR : Rep) (ER : Rep) (Lit : ScillaLiteral) = struct (** [SendMsgs(MS)] represents sending messages: [send MS] *) | CreateEvnt of ER.rep SIdentifier.t (** [CreateEvnt(E)] represents emitting an event: [event E] *) - | CallProc of SR.rep SIdentifier.t * ER.rep SIdentifier.t list - (** [CallProc(F, [A1, ... An])] is a procedure call: [F A1 ... An] *) + | CallProc of + ER.rep SIdentifier.t option + * SR.rep SIdentifier.t + * ER.rep SIdentifier.t list + (** [CallProc(I, P, [A1, ... An])] is a procedure call: [I = P A1 ... An] *) | Throw of ER.rep SIdentifier.t option (** [Throw(I)] represents: [throw I] *) | GasStmt of SGasCharge.gas_charge diff --git a/src/eval/Eval.ml b/src/eval/Eval.ml index cdd422a9f..1049b25dc 100644 --- a/src/eval/Eval.ml +++ b/src/eval/Eval.ml @@ -470,8 +470,8 @@ let rec stmt_eval conf stmts = | AcceptPayment -> let%bind conf' = Configuration.accept_incoming conf in stmt_eval conf' sts - | Return _id -> (* TODO *) - let%bind conf' = Configuration.accept_incoming conf in + | Return _id -> + let%bind conf' = Configuration.procedure_return conf in stmt_eval conf' sts (* Caution emitting messages does not change balance immediately! *) | SendMsgs ms -> diff --git a/src/eval/EvalUtil.ml b/src/eval/EvalUtil.ml index a5d82be50..efd5a5915 100644 --- a/src/eval/EvalUtil.ml +++ b/src/eval/EvalUtil.ml @@ -426,6 +426,11 @@ module Configuration = struct fail0 ~kind:"Unrecognized balance literal at sender" ~inst:(pp_literal sender_balance_l) + (** TODO *) + let procedure_return st = + Printf.printf "Return from %s\n" (List.hd_exn st.procedures |> fun c -> (SIdentifier.Name.as_string (SIdentifier.get_id c.comp_name))); + pure @@ st + (* Finds a procedure proc_name, and returns the procedure and the list of procedures in scope for that procedure *) let lookup_procedure st proc_name = From 8989a078e1713ff5493d360c2f92c6153028639b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 7 Nov 2022 12:00:29 +0700 Subject: [PATCH 10/41] chore(dcd): Simplify code. NFC. --- src/base/DeadCodeDetector.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/DeadCodeDetector.ml b/src/base/DeadCodeDetector.ml index a43ad9b8d..9e5928f27 100644 --- a/src/base/DeadCodeDetector.ml +++ b/src/base/DeadCodeDetector.ml @@ -437,10 +437,10 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct proc_dict := p :: !proc_dict; (ERSet.add lv l, adts, ctrs) | Bind (i, e) -> - let live_vars_no_i = - ERSet.filter ~f:(fun x -> not @@ SCIdentifier.equal i x) lv - in if ERSet.mem lv i then + let live_vars_no_i = + ERSet.filter ~f:(fun x -> not @@ SCIdentifier.equal i x) lv + in let e_live_vars, adts', ctrs' = expr_iter e in ( ERSet.union e_live_vars live_vars_no_i, SCIdentifierSet.union adts' adts, From e03e0a91d6eb3e81bece0483dca43cc48bad3bdf Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 9 Nov 2022 12:05:11 +0700 Subject: [PATCH 11/41] feat(all): Support return values in `CallProc` statement --- src/base/Callgraph.ml | 4 ++-- src/base/Cashflow.ml | 10 +++++---- src/base/DeadCodeDetector.ml | 12 ++++++++-- src/base/Disambiguate.ml | 13 +++++++++-- src/base/PatternChecker.ml | 4 ++-- src/base/Recursion.ml | 4 ++-- src/base/SanityChecker.ml | 6 ++--- src/base/Syntax.ml | 2 +- src/base/SyntaxAnnotMapper.ml | 5 +++-- src/base/TypeChecker.ml | 42 ++++++++++++++++++++++++----------- src/base/TypeInfo.ml | 5 ++++- 11 files changed, 73 insertions(+), 34 deletions(-) diff --git a/src/base/Callgraph.ml b/src/base/Callgraph.ml index 5c5c633a4..ee27f76ac 100644 --- a/src/base/Callgraph.ml +++ b/src/base/Callgraph.ml @@ -186,8 +186,8 @@ module ScillaCallgraph (SR : Rep) (ER : Rep) = struct let rec visit_stmt (s, _annot) = match s with | Bind (_id, ea) -> collect_funcalls ea collected_nodes - | CallProc (id, _) | Iterate (_, id) -> ( - find_node collected_nodes id |> function + | CallProc (_, proc, _) | Iterate (_, proc) -> ( + find_node collected_nodes proc |> function | Some n -> NodeSet.singleton n | None -> emp_nodes_set) | MatchStmt (_id, arms) -> diff --git a/src/base/Cashflow.ml b/src/base/Cashflow.ml index 51cbab988..bdc448190 100644 --- a/src/base/Cashflow.ml +++ b/src/base/Cashflow.ml @@ -230,8 +230,9 @@ struct | Return i -> CFSyntax.Return (add_noinfo_to_ident i) | SendMsgs x -> CFSyntax.SendMsgs (add_noinfo_to_ident x) | CreateEvnt x -> CFSyntax.CreateEvnt (add_noinfo_to_ident x) - | CallProc (p, args) -> - CFSyntax.CallProc (p, List.map args ~f:add_noinfo_to_ident) + | CallProc (id_opt, p, args) -> + let id = Option.map id_opt ~f:(fun id -> add_noinfo_to_ident id) in + CFSyntax.CallProc (id, p, List.map args ~f:add_noinfo_to_ident) | Iterate (l, p) -> CFSyntax.Iterate (add_noinfo_to_ident l, p) | Throw xopt -> ( match xopt with @@ -1914,7 +1915,8 @@ struct new_local_env, ctr_tag_map, not @@ [%equal: ECFR.money_tag] (get_id_tag e) e_tag ) - | CallProc (p, args) -> + | CallProc (id_opt, p, args) -> + (* TODO: How does procedure call affects cash flow? *) let new_args = List.map args ~f:(fun arg -> update_id_tag arg (lookup_var_tag2 arg local_env param_env)) @@ -1931,7 +1933,7 @@ struct | Ok res -> res | Unequal_lengths -> false in - ( CallProc (p, new_args), + ( CallProc (id_opt, p, new_args), param_env, field_env, local_env, diff --git a/src/base/DeadCodeDetector.ml b/src/base/DeadCodeDetector.ml index 9e5928f27..d143d471d 100644 --- a/src/base/DeadCodeDetector.ml +++ b/src/base/DeadCodeDetector.ml @@ -430,9 +430,17 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct match topt with | Some x -> (ERSet.add lv x, adts, ctrs) | None -> (lv, adts, ctrs)) - | CallProc (p, al) -> + | CallProc (id_opt, p, al) -> proc_dict := p :: !proc_dict; - (ERSet.of_list al |> ERSet.union lv, adts, ctrs) + let lv' = + match id_opt with + | Some id when ERSet.mem lv id -> ERSet.add lv id + | Some id -> + warn "Unused local binding: " id ER.get_loc; + ERSet.add lv id + | None -> lv + in + (ERSet.of_list al |> ERSet.union lv', adts, ctrs) | Iterate (l, p) -> proc_dict := p :: !proc_dict; (ERSet.add lv l, adts, ctrs) diff --git a/src/base/Disambiguate.ml b/src/base/Disambiguate.ml index b11b2c8e1..5b5b5918e 100644 --- a/src/base/Disambiguate.ml +++ b/src/base/Disambiguate.ml @@ -700,7 +700,14 @@ module ScillaDisambiguation (SR : Rep) (ER : Rep) = struct disambiguate_identifier_helper var_dict_acc (SR.get_loc rep) e in pure @@ (PostDisSyntax.CreateEvnt dis_e, var_dict_acc) - | CallProc (proc, args) -> + | CallProc (id_opt, proc, args) -> + let%bind dis_id_opt = + match id_opt with + | Some id -> + let%bind dis_id = name_def_as_simple_global id in + pure @@ Some dis_id + | None -> pure @@ None + in (* Only locally defined procedures are allowed *) let%bind dis_proc = name_def_as_simple_global proc in let%bind dis_args = @@ -708,7 +715,9 @@ module ScillaDisambiguation (SR : Rep) (ER : Rep) = struct ~f: (disambiguate_identifier_helper var_dict_acc (SR.get_loc rep)) in - pure @@ (PostDisSyntax.CallProc (dis_proc, dis_args), var_dict_acc) + pure + @@ ( PostDisSyntax.CallProc (dis_id_opt, dis_proc, dis_args), + var_dict_acc ) | Throw xopt -> let%bind dis_xopt = option_mapM xopt diff --git a/src/base/PatternChecker.ml b/src/base/PatternChecker.ml index 663c35898..ac0deffe4 100644 --- a/src/base/PatternChecker.ml +++ b/src/base/PatternChecker.ml @@ -286,8 +286,8 @@ struct | Iterate (l, p) -> pure @@ (CheckedPatternSyntax.Iterate (l, p), rep) | SendMsgs i -> pure @@ (CheckedPatternSyntax.SendMsgs i, rep) | CreateEvnt i -> pure @@ (CheckedPatternSyntax.CreateEvnt i, rep) - | CallProc (p, args) -> - pure @@ (CheckedPatternSyntax.CallProc (p, args), rep) + | CallProc (id_opt, p, args) -> + pure @@ (CheckedPatternSyntax.CallProc (id_opt, p, args), rep) | Throw i -> pure @@ (CheckedPatternSyntax.Throw i, rep) | GasStmt g -> pure (CheckedPatternSyntax.GasStmt (pm_check_gas_charge g), rep) diff --git a/src/base/Recursion.ml b/src/base/Recursion.ml index 10b1d0406..9e7365bbe 100644 --- a/src/base/Recursion.ml +++ b/src/base/Recursion.ml @@ -218,9 +218,9 @@ module ScillaRecursion (SR : Rep) (ER : Rep) = struct | Iterate (l, p) -> pure @@ RecursionSyntax.Iterate (l, p) | SendMsgs msg -> pure @@ RecursionSyntax.SendMsgs msg | CreateEvnt evnt -> pure @@ RecursionSyntax.CreateEvnt evnt - | CallProc (p, args) -> + | CallProc (id_opt, p, args) -> if is_proc_in_scope (get_id p) then - pure @@ RecursionSyntax.CallProc (p, args) + pure @@ RecursionSyntax.CallProc (id_opt, p, args) else fail1 ~kind:"Procedure is not in scope" ~inst:(as_error_string p) (SR.get_loc rep) diff --git a/src/base/SanityChecker.ml b/src/base/SanityChecker.ml index 9e985fea1..5b5ff4969 100644 --- a/src/base/SanityChecker.ml +++ b/src/base/SanityChecker.ml @@ -552,8 +552,8 @@ struct List.fold_left stmts ~init:acc ~f:(fun acc s -> used_in_unknown_calls m unboxed_options s |> List.append acc) |> List.append acc) - | CallProc (id, args) -> - if not @@ Map.mem m (get_id id) then + | CallProc (_id_opt, proc, args) -> + if not @@ Map.mem m (get_id proc) then List.fold_left args ~init:[] ~f:(fun acc arg -> List.fold_left unboxed_options ~init:[] ~f:(fun acc opt -> if SCIdentifier.equal arg opt then @@ -684,7 +684,7 @@ struct collect_matches_in_stmt m sa |> List.append acc) |> List.append acc) |> List.append [ get_id id ] - | CallProc (id, args) -> ( + | CallProc (_id_opt, id, args) -> ( match Map.find m (get_id id) with | Some arg_matches -> List.foldi args ~init:[] ~f:(fun i acc arg -> diff --git a/src/base/Syntax.ml b/src/base/Syntax.ml index 22c3f0b57..12e7237a2 100644 --- a/src/base/Syntax.ml +++ b/src/base/Syntax.ml @@ -653,7 +653,7 @@ module ScillaSyntax (SR : Rep) (ER : Rep) (Lit : ScillaLiteral) = struct sprintf "Error in sending messages `%s`:\n" (as_error_string i) | CreateEvnt i -> sprintf "Error in create event `%s`:\n" (as_error_string i) - | CallProc (p, _) -> + | CallProc (_, p, _) -> sprintf "Error in call of procedure '%s':\n" (as_error_string p) | GasStmt _ -> "Error in type checking gas charge. This shouldn't happen." | Throw i -> diff --git a/src/base/SyntaxAnnotMapper.ml b/src/base/SyntaxAnnotMapper.ml index afced3400..65ebc1a9c 100644 --- a/src/base/SyntaxAnnotMapper.ml +++ b/src/base/SyntaxAnnotMapper.ml @@ -221,9 +221,10 @@ struct OutputSyntax.Iterate (map_id fe list, map_id fs proc) | SendMsgs id -> OutputSyntax.SendMsgs (map_id fe id) | CreateEvnt id -> OutputSyntax.CreateEvnt (map_id fe id) - | CallProc (proc, args) -> + | CallProc (id_opt, proc, args) -> + let id = Option.map ~f:(fun id -> map_id fe id) id_opt in OutputSyntax.CallProc - (map_id fs proc, List.map args ~f:(fun a -> map_id fe a)) + (id, map_id fs proc, List.map args ~f:(fun a -> map_id fe a)) | Throw oid -> OutputSyntax.Throw (Option.map oid ~f:(fun id -> map_id fe id)) | GasStmt gc -> OutputSyntax.GasStmt (gas_charge gc) diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 182185f8e..a26955df5 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -555,7 +555,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct type stmt_tenv = { pure : TEnv.t; fields : TEnv.t; - procedures : (TCName.t * TCType.t list) list; + procedures : (TCName.t * (TCType.t list * TCType.t option)) list; } let lookup_proc env pname = @@ -985,26 +985,42 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct @@ add_stmt_to_stmts_env_gas (TypedSyntax.CreateEvnt typed_i, rep) checked_stmts - | CallProc (p, args) -> - let%bind typed_args = - let%bind targs, typed_actuals = type_actuals env.pure args in + | CallProc (id_opt, p, args) -> + let%bind arg_typs, ret_ty_opt = match lookup_proc env p with - | Some arg_typs -> - let%bind _ = - fromR_TE - @@ proc_type_applies arg_typs targs ~lc:(SR.get_loc rep) - in - pure typed_actuals + | Some (arg_typs, ret_ty_opt) -> pure (arg_typs, ret_ty_opt) | None -> fail (mk_type_error1 ~kind:"Procedure not found" ~inst:(as_error_string p) (SR.get_loc (get_rep p))) in + let%bind typed_id_opt = + match id_opt with + | None -> pure @@ None + | Some id -> ( + match ret_ty_opt with + | Some ret_ty -> + pure @@ Some (add_type_to_ident id (mk_qual_tp ret_ty)) + | None -> + fail + (mk_type_error1 + ~kind:"Return type for procedure not found" + ~inst:(as_error_string p) + (SR.get_loc (get_rep p)))) + in + let%bind typed_args = + let%bind targs, typed_actuals = type_actuals env.pure args in + let%bind _ = + fromR_TE + @@ proc_type_applies arg_typs targs ~lc:(SR.get_loc rep) + in + pure typed_actuals + in let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas - (TypedSyntax.CallProc (p, typed_args), rep) + (TypedSyntax.CallProc (typed_id_opt, p, typed_args), rep) checked_stmts | Iterate (l, p) -> ( let%bind lt = @@ -1013,7 +1029,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct in let l_type = rr_typ lt in match lookup_proc env p with - | Some [ arg_typ ] -> + | Some ([ arg_typ ], _) -> let%bind () = fromR_TE (* The procedure accepts an element of l. *) @@ -1108,7 +1124,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct | CompProc -> let proc_sig = List.map comp_params ~f:snd in List.Assoc.add procedures ~equal:[%equal: TCName.t] (get_id comp_name) - proc_sig + (proc_sig, comp_return) in pure @@ ( { diff --git a/src/base/TypeInfo.ml b/src/base/TypeInfo.ml index 4e7580134..c24891824 100644 --- a/src/base/TypeInfo.ml +++ b/src/base/TypeInfo.ml @@ -136,7 +136,10 @@ struct | ReplicateContr (addr, iparams) -> [ addr; iparams ])) | TypeCast (v, r, _) -> [ calc_ident_locs v; calc_ident_locs r ] | AcceptPayment | GasStmt _ -> [] - | CallProc (_, il) -> List.map il ~f:calc_ident_locs + | CallProc (id_opt, _, il) -> + Option.value_map id_opt ~default:[] ~f:(fun id -> + [ calc_ident_locs id ]) + @ List.map il ~f:calc_ident_locs | Iterate (l, _) -> [ calc_ident_locs l ] | Throw iopt -> ( match iopt with Some i -> [ calc_ident_locs i ] | None -> [])) From 573e6708574bf6eadaf35322b38c4618eb35d44d Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 9 Nov 2022 18:03:08 +0700 Subject: [PATCH 12/41] feat(parser): Disambiguate between functions and procedures --- src/base/FrontEndParser.ml | 53 +++++++++++++++++++++++++++++++++++++- src/base/ParserUtil.ml | 2 +- src/base/ScillaParser.mly | 10 ++++--- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/base/FrontEndParser.ml b/src/base/FrontEndParser.ml index d721eb29f..5d387fffc 100644 --- a/src/base/FrontEndParser.ml +++ b/src/base/FrontEndParser.ml @@ -32,10 +32,56 @@ module ScillaFrontEndParser (Literal : ScillaLiteral) = struct module Lexer = ScillaLexer.MkLexer (FESyntax) module MInter = Parser.MenhirInterpreter module FEPType = FESyntax.SType + module FEPIdentifier = FEPType.TIdentifier + + module FEPIdentifierComp = struct + include FEPIdentifier.Name + include Comparable.Make (FEPIdentifier.Name) + end + + module FEPIdentifierSet = Set.Make (FEPIdentifierComp) + + let emp_idset = FEPIdentifierSet.empty (* TODO: Use DebugMessage perr/pout instead of fprintf. *) let fail_err msg lexbuf = fail1 ~kind:msg ?inst:None (toLoc lexbuf.lex_curr_p) + (** Disambiguates calls of procedures without values and pure function calls. + They have the same syntax: [id = foo param1 param2]. Therefore, the + parser doesn't know what is actually is called and saves such cases as + [Bind(id, App(...))]. This step finishes parsing and places + [CallProc(Some(id), ...)] statements when the contract contains a + procedure [id]. *) + let disambiguate_calls cmod = + let open FESyntax in + let procedures_with_return = + List.fold_left cmod.contr.ccomps ~init:emp_idset ~f:(fun s comp -> + if Option.is_some comp.comp_return then + FEPIdentifierSet.add s (FEPIdentifier.get_id comp.comp_name) + else s) + in + let disambiguate_stmt (stmt, annot) = + match stmt with + | Bind (id, (App (f, args), _)) + when Set.mem procedures_with_return (FEPIdentifier.get_id f) -> + (CallProc (Some id, f, args), annot) + | _ -> (stmt, annot) + in + let contr' = + { + cmod.contr with + ccomps = + List.map cmod.contr.ccomps ~f:(fun comp -> + { + comp with + comp_body = + List.map comp.comp_body ~f:(fun stmt -> + disambiguate_stmt stmt); + }); + } + in + { cmod with contr = contr' } + let parse_lexbuf checkpoint_starter lexbuf filename = lexbuf.lex_curr_p <- { lexbuf.lex_curr_p with pos_fname = filename }; (* Supply of tokens *) @@ -86,6 +132,11 @@ module ScillaFrontEndParser (Literal : ScillaLiteral) = struct let parse_expr_from_stdin () = parse_stdin Parser.Incremental.exp_term let parse_lmodule filename = parse_file Parser.Incremental.lmodule filename - let parse_cmodule filename = parse_file Parser.Incremental.cmodule filename + + let parse_cmodule filename = + let open Result.Let_syntax in + let%bind cmod = parse_file Parser.Incremental.cmodule filename in + pure @@ disambiguate_calls cmod + let get_comments () = Lexer.get_comments () end diff --git a/src/base/ParserUtil.ml b/src/base/ParserUtil.ml index e17491e29..18282dc42 100644 --- a/src/base/ParserUtil.ml +++ b/src/base/ParserUtil.ml @@ -140,7 +140,7 @@ module type Syn = sig | SendMsgs of ParserRep.rep SIdentifier.t | CreateEvnt of ParserRep.rep SIdentifier.t | CallProc of - ParserRep.rep SIdentifier.t + ParserRep.rep SIdentifier.t option * ParserRep.rep SIdentifier.t * ParserRep.rep SIdentifier.t list | Throw of ParserRep.rep SIdentifier.t option diff --git a/src/base/ScillaParser.mly b/src/base/ScillaParser.mly index e548aa376..d664c369d 100644 --- a/src/base/ScillaParser.mly +++ b/src/base/ScillaParser.mly @@ -409,7 +409,11 @@ stmt: | l = ID; FETCH; r = sid { (Load (to_loc_id l (toLoc $startpos(l)), ParserIdentifier.mk_id r (toLoc $startpos(r))), toLoc $startpos) } | r = remote_fetch_stmt { r } | l = ID; ASSIGN; r = sid { (Store ( to_loc_id l (toLoc $startpos(l)), ParserIdentifier.mk_id r (toLoc $startpos(r))), toLoc $startpos) } -| l = ID; EQ; r = exp { (Bind ( to_loc_id l (toLoc $startpos(l)), r), toLoc $startpos) } +| l = ID; EQ; r = exp { + (* This [Bind] may contain both application of a function or call a procedure + with return type because they have the same syntax. We always save it as + [Bind] to disambiguate it later. *) + ( Bind ( to_loc_id l (toLoc $startpos(l)), r), toLoc $startpos ) } | l = ID; FETCH; AND; c = CID; args_opt = option(bcfetch_args) { let bcinfo = build_bcfetch c (Option.value args_opt ~default:[]) (toLoc $startpos) in (ReadFromBC ( to_loc_id l (toLoc $startpos(l)), bcinfo), toLoc $startpos) @@ -429,10 +433,10 @@ stmt: | THROW; mopt = option(sid); { Throw (Core.Option.map mopt ~f:(fun m -> (ParserIdentifier.mk_id m (toLoc $startpos(mopt))))), toLoc $startpos } | MATCH; x = sid; WITH; cs=list(stmt_pm_clause); END { (MatchStmt (ParserIdentifier.mk_id x (toLoc $startpos(x)), cs), toLoc $startpos) } -| (* procedure call *) +| (* calling a procedure without return type *) p = component_id; args = list(sident) - { (CallProc (p, args), toLoc $startpos) } + { (CallProc (None, p, args), toLoc $startpos) } | (* list iterator *) FORALL; l = sident; p = component_id { Iterate (l, p), toLoc $startpos } From 7d466cc489c2e3fa9be9e002dd16b2ffed31efd4 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 10 Nov 2022 14:54:42 +0700 Subject: [PATCH 13/41] feat(merge,fmt): Support return --- src/eval/Eval.ml | 3 ++- src/formatter/ExtendedSyntax.ml | 11 ++++++----- src/formatter/Formatter.ml | 11 ++++++++--- src/merge/Merge.ml | 9 ++++++--- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/eval/Eval.ml b/src/eval/Eval.ml index 1049b25dc..aac30becf 100644 --- a/src/eval/Eval.ml +++ b/src/eval/Eval.ml @@ -484,7 +484,8 @@ let rec stmt_eval conf stmts = in let%bind conf' = Configuration.create_event conf eparams_resolved in stmt_eval conf' sts - | CallProc (p, actuals) -> + | CallProc (_id_opt, p, actuals) -> + (* TODO *) (* Resolve the actuals *) let%bind args = mapM actuals ~f:(fun arg -> fromR @@ Env.lookup conf.env arg) diff --git a/src/formatter/ExtendedSyntax.ml b/src/formatter/ExtendedSyntax.ml index b4828d82d..ee9a4b104 100644 --- a/src/formatter/ExtendedSyntax.ml +++ b/src/formatter/ExtendedSyntax.ml @@ -108,7 +108,7 @@ struct | Iterate of ER.rep id_ann * SR.rep id_ann | SendMsgs of ER.rep id_ann | CreateEvnt of ER.rep id_ann - | CallProc of SR.rep id_ann * ER.rep id_ann list + | CallProc of ER.rep id_ann option * SR.rep id_ann * ER.rep id_ann list | Throw of ER.rep id_ann option | GasStmt of SGasCharge.gas_charge [@@deriving sexp] @@ -659,11 +659,12 @@ struct let c = comment (loc_end_er id) in let id' = extend_er_id tr id in (ExtSyn.CreateEvnt id', ann, c) - | Syn.CallProc (id, args) -> - let c = comment (loc_end_sr id) in - let id' = extend_sr_id tr id in + | Syn.CallProc (id_opt, proc, args) -> + let id_opt' = Option.map id_opt ~f:(fun id -> extend_er_id tr id) in + let c = comment (loc_end_sr proc) in + let proc' = extend_sr_id tr proc in let args' = List.map args ~f:(fun arg -> extend_er_id tr arg) in - (ExtSyn.CallProc (id', args'), ann, c) + (ExtSyn.CallProc (id_opt', proc', args'), ann, c) | Syn.Throw id_opt -> ( match id_opt with | Some id -> diff --git a/src/formatter/Formatter.ml b/src/formatter/Formatter.ml index 8de6ffdea..6bd275b92 100644 --- a/src/formatter/Formatter.ml +++ b/src/formatter/Formatter.ml @@ -433,9 +433,14 @@ struct send_kwd ^//^ of_ann_id msgs | Ast.CreateEvnt events -> event_kwd ^//^ of_ann_id events - | Ast.CallProc (proc, args) -> - if List.is_empty args then of_ann_id proc - else of_ann_id proc ^//^ of_ann_ids args + | Ast.CallProc (id_opt, proc, args) -> + let call = + if List.is_empty args then of_ann_id proc + else of_ann_id proc ^//^ of_ann_ids args + in + (match id_opt with + | None -> call + | Some id -> of_ann_id id ^^^ equals ^//^ call) | Ast.Throw oexc -> (match oexc with | None -> throw_kwd diff --git a/src/merge/Merge.ml b/src/merge/Merge.ml index f080e5c9d..eee5e9ec7 100644 --- a/src/merge/Merge.ml +++ b/src/merge/Merge.ml @@ -416,10 +416,13 @@ module ScillaMerger (SR : Rep) (ER : Rep) = struct | Bind (id, expr) -> let id' = rename_local_er renames_map id in (Bind (id', rename_expr renames_map expr), annot) - | CallProc (id, args) -> - let id' = rename_local_sr renames_map id in + | CallProc (id_opt, proc, args) -> + let id_opt' = + Option.map id_opt ~f:(fun id -> rename_local_er renames_map id) + in + let proc' = rename_local_sr renames_map proc in let args' = List.map args ~f:(fun a -> rename_local_er renames_map a) in - (CallProc (id', args'), annot) + (CallProc (id_opt', proc', args'), annot) | Iterate (list, id) -> let id' = rename_local_sr renames_map id in let list' = rename_local_er renames_map list in From 5f2f54f13470a056a0d9866bf55005bf666b98f1 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 11 Nov 2022 13:27:13 +0700 Subject: [PATCH 14/41] feat(parser): Disambiguate `[Bind(id, Var(proc))]` which are procedure calls --- src/base/FrontEndParser.ml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/base/FrontEndParser.ml b/src/base/FrontEndParser.ml index 5d387fffc..d9dbc149a 100644 --- a/src/base/FrontEndParser.ml +++ b/src/base/FrontEndParser.ml @@ -46,12 +46,14 @@ module ScillaFrontEndParser (Literal : ScillaLiteral) = struct (* TODO: Use DebugMessage perr/pout instead of fprintf. *) let fail_err msg lexbuf = fail1 ~kind:msg ?inst:None (toLoc lexbuf.lex_curr_p) - (** Disambiguates calls of procedures without values and pure function calls. - They have the same syntax: [id = foo param1 param2]. Therefore, the - parser doesn't know what is actually is called and saves such cases as - [Bind(id, App(...))]. This step finishes parsing and places - [CallProc(Some(id), ...)] statements when the contract contains a - procedure [id]. *) + (** Disambiguates calls of procedures without values and pure function calls + and variables. + They have the same syntax: [id = proc param1 param2] or [id = proc]. + Therefore, the parser doesn't know what is actually is called and saves + such cases as [Bind(id, App(proc, [param1, param2]))] or + [Bind(id, Var(proc)]. + This function finishes parsing and places [CallProc(Some(id), ...)] + statements when the contract contains a procedure [id]. *) let disambiguate_calls cmod = let open FESyntax in let procedures_with_return = @@ -65,6 +67,9 @@ module ScillaFrontEndParser (Literal : ScillaLiteral) = struct | Bind (id, (App (f, args), _)) when Set.mem procedures_with_return (FEPIdentifier.get_id f) -> (CallProc (Some id, f, args), annot) + | Bind (id, (Var f, _)) + when Set.mem procedures_with_return (FEPIdentifier.get_id f) -> + (CallProc (Some id, f, []), annot) | _ -> (stmt, annot) in let contr' = From 719ffb77e84cdf2c5776545e046121a360f8fc0b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 11 Nov 2022 15:14:11 +0700 Subject: [PATCH 15/41] feat(eval): Support return values --- src/eval/Eval.ml | 15 +++++++++++---- src/eval/EvalUtil.ml | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/eval/Eval.ml b/src/eval/Eval.ml index aac30becf..f76e1e9a2 100644 --- a/src/eval/Eval.ml +++ b/src/eval/Eval.ml @@ -470,8 +470,9 @@ let rec stmt_eval conf stmts = | AcceptPayment -> let%bind conf' = Configuration.accept_incoming conf in stmt_eval conf' sts - | Return _id -> - let%bind conf' = Configuration.procedure_return conf in + | Return id -> + let%bind id_resolved = fromR @@ Configuration.lookup conf id in + let conf' = { conf with return_value = Some id_resolved } in stmt_eval conf' sts (* Caution emitting messages does not change balance immediately! *) | SendMsgs ms -> @@ -484,8 +485,7 @@ let rec stmt_eval conf stmts = in let%bind conf' = Configuration.create_event conf eparams_resolved in stmt_eval conf' sts - | CallProc (_id_opt, p, actuals) -> - (* TODO *) + | CallProc (id_opt, p, actuals) -> (* Resolve the actuals *) let%bind args = mapM actuals ~f:(fun arg -> fromR @@ Env.lookup conf.env arg) @@ -493,6 +493,12 @@ let rec stmt_eval conf stmts = let%bind proc, p_rest = Configuration.lookup_procedure conf p in (* Apply procedure. No gas charged for the application *) let%bind conf' = try_apply_as_procedure conf proc p_rest args in + (* Bind the return of [p] if it returns. *) + let%bind conf' = + match id_opt with + | Some id -> Configuration.procedure_return conf' id + | None -> pure @@ conf' + in stmt_eval conf' sts | Iterate (l, p) -> let%bind l_actual = fromR @@ Env.lookup conf.env l in @@ -939,6 +945,7 @@ let handle_message (tenv, incoming_funds, procedures, stmts, tname) cstate = incoming_funds; procedures; component_stack = [ tname ]; + return_value = None; emitted = []; events = []; } diff --git a/src/eval/EvalUtil.ml b/src/eval/EvalUtil.ml index efd5a5915..808562f67 100644 --- a/src/eval/EvalUtil.ml +++ b/src/eval/EvalUtil.ml @@ -125,6 +125,8 @@ module Configuration = struct procedures : EvalSyntax.component list; (* The stack of procedure call, starting from the externally invoked transition. *) component_stack : ER.rep EvalIdentifier.t list; + (* Value to return from the procedure *) + return_value : EvalLiteral.t option; (* Emitted messages *) emitted : EvalLiteral.t list; (* Emitted events *) @@ -426,10 +428,16 @@ module Configuration = struct fail0 ~kind:"Unrecognized balance literal at sender" ~inst:(pp_literal sender_balance_l) - (** TODO *) - let procedure_return st = - Printf.printf "Return from %s\n" (List.hd_exn st.procedures |> fun c -> (SIdentifier.Name.as_string (SIdentifier.get_id c.comp_name))); - pure @@ st + (** Implements returning value from the current procedure. + The return result will be bind to [id]. *) + let procedure_return st id = + match st.return_value with + | Some ret -> + let st' = bind st (get_id id) ret in + pure @@ { st' with return_value = None } + | None -> + fail0 ~kind:"Trying to bind to a procedure that doesn't return" + ~inst:(EvalName.as_error_string (get_id id)) (* Finds a procedure proc_name, and returns the procedure and the list of procedures in scope for that procedure *) From b5c2e71d976ff25337b6348aede077a23ac4a775 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 16:15:46 +0700 Subject: [PATCH 16/41] chore(checker): Rename, because this may be both `cmod` and `lmod` --- src/base/Checker.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/Checker.ml b/src/base/Checker.ml index 63212a439..f72ca9706 100644 --- a/src/base/Checker.ml +++ b/src/base/Checker.ml @@ -63,10 +63,10 @@ module CG = ScillaCallgraph (TCSRep) (TCERep) (* Check that the module parses *) let check_parsing ctr syn = - let cmod = FEParser.parse_file syn ctr in - if Result.is_ok cmod then + let ast = FEParser.parse_file syn ctr in + if Result.is_ok ast then plog @@ sprintf "\n[Parsing]:\n module [%s] is successfully parsed.\n" ctr; - cmod + ast (* Change local names to global names *) let disambiguate_lmod lmod elibs names_and_addresses this_address = From 24532c7205ae03d121964d631192deb0e566adec Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 16:43:36 +0700 Subject: [PATCH 17/41] fix(checker): Disambiguate calls in cmod --- src/base/Checker.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/base/Checker.ml b/src/base/Checker.ml index f72ca9706..02e7b21fa 100644 --- a/src/base/Checker.ml +++ b/src/base/Checker.ml @@ -309,6 +309,7 @@ let check_cmodule cli = wrap_error_with_gas initial_gas @@ check_parsing cli.input_file Parser.Incremental.cmodule in + let cmod = FEParser.disambiguate_calls cmod in (* Import whatever libs we want. *) let this_address_opt, init_address_map = Option.value_map cli.init_file ~f:get_init_this_address_and_extlibs From e30fb3e26483602bcb00ac947bac89a9ab889d60 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 16:43:53 +0700 Subject: [PATCH 18/41] fix(typechecker): Add new binds after procedure call to env --- src/base/TypeChecker.ml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index a26955df5..03fec73c0 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -995,13 +995,30 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~inst:(as_error_string p) (SR.get_loc (get_rep p))) in - let%bind typed_id_opt = + let%bind typed_args = + let%bind targs, typed_actuals = type_actuals env.pure args in + let%bind _ = + fromR_TE + @@ proc_type_applies arg_typs targs ~lc:(SR.get_loc rep) + in + pure typed_actuals + in + let%bind typed_id_opt, checked_stmts = match id_opt with - | None -> pure @@ None + | None -> + let%bind checked_stmts = type_stmts comp sts get_loc env in + pure @@ (None, checked_stmts) | Some id -> ( match ret_ty_opt with | Some ret_ty -> - pure @@ Some (add_type_to_ident id (mk_qual_tp ret_ty)) + let typed_id = add_type_to_ident id (mk_qual_tp ret_ty) in + let%bind checked_stmts = + with_extended_env env get_tenv_pure + [ (id, ret_ty) ] + [] + (type_stmts comp sts get_loc) + in + pure @@ (Some typed_id, checked_stmts) | None -> fail (mk_type_error1 @@ -1009,15 +1026,6 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct ~inst:(as_error_string p) (SR.get_loc (get_rep p)))) in - let%bind typed_args = - let%bind targs, typed_actuals = type_actuals env.pure args in - let%bind _ = - fromR_TE - @@ proc_type_applies arg_typs targs ~lc:(SR.get_loc rep) - in - pure typed_actuals - in - let%bind checked_stmts = type_stmts comp sts get_loc env in pure @@ add_stmt_to_stmts_env_gas (TypedSyntax.CallProc (typed_id_opt, p, typed_args), rep) From 1ce75d4ee400623de739887a86e2e572a95e2543 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 17:07:39 +0700 Subject: [PATCH 19/41] chore(test): Improve a test for formatter --- .../procedure-return-1.scilla | 31 +++++++++++++++++++ .../ast_does_not_change.t/return-1.scilla | 20 ------------ 2 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 tests/formatter/ast_does_not_change.t/procedure-return-1.scilla delete mode 100644 tests/formatter/ast_does_not_change.t/return-1.scilla diff --git a/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla b/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla new file mode 100644 index 000000000..97f62c166 --- /dev/null +++ b/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla @@ -0,0 +1,31 @@ +scilla_version 0 + +library Return1 + +let one = Uint32 1 + +contract Return1() + +field f : Uint32 = Uint32 0 + +procedure return_one() -> Uint32 + a = one; + return a +end + +procedure id(x: Uint32) -> Uint32 + return x +end + +procedure add(lhs: Uint32, rhs: Uint32) -> Uint32 + s = builtin add lhs rhs; + return s +end + +transition f_add_one() + one = return_one; + f_cur <- f; + sum = add f_cur one; + sum_id = id sum; + f := sum +end diff --git a/tests/formatter/ast_does_not_change.t/return-1.scilla b/tests/formatter/ast_does_not_change.t/return-1.scilla deleted file mode 100644 index ae28bc0c6..000000000 --- a/tests/formatter/ast_does_not_change.t/return-1.scilla +++ /dev/null @@ -1,20 +0,0 @@ -scilla_version 0 - -library Return1 - -contract Return1() - -procedure no_return() - a = _creation_block; - return a -end - -procedure incorrect_return_type() -> (String) - a = _creation_block; - return a -end - -procedure return_1() -> BNum - a = _creation_block; - return a -end From 2c7e0569f37ab7cf512488884f3f66e525c153e1 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 17:08:37 +0700 Subject: [PATCH 20/41] feat(test): Add runner test for `return` --- tests/contracts/procedure-return-1.scilla | 31 +++++++++++++++++++ tests/runner/Testcontracts.ml | 2 ++ .../procedure-return-1/blockchain_0.json | 7 +++++ .../procedure-return-1/blockchain_1.json | 7 +++++ tests/runner/procedure-return-1/init.json | 17 ++++++++++ .../runner/procedure-return-1/message_0.json | 7 +++++ .../runner/procedure-return-1/message_1.json | 7 +++++ tests/runner/procedure-return-1/output_0.json | 19 ++++++++++++ tests/runner/procedure-return-1/output_1.json | 20 ++++++++++++ tests/runner/procedure-return-1/state_0.json | 12 +++++++ tests/runner/procedure-return-1/state_1.json | 12 +++++++ 11 files changed, 141 insertions(+) create mode 100644 tests/contracts/procedure-return-1.scilla create mode 100644 tests/runner/procedure-return-1/blockchain_0.json create mode 100644 tests/runner/procedure-return-1/blockchain_1.json create mode 100644 tests/runner/procedure-return-1/init.json create mode 100644 tests/runner/procedure-return-1/message_0.json create mode 100644 tests/runner/procedure-return-1/message_1.json create mode 100644 tests/runner/procedure-return-1/output_0.json create mode 100644 tests/runner/procedure-return-1/output_1.json create mode 100644 tests/runner/procedure-return-1/state_0.json create mode 100644 tests/runner/procedure-return-1/state_1.json diff --git a/tests/contracts/procedure-return-1.scilla b/tests/contracts/procedure-return-1.scilla new file mode 100644 index 000000000..97f62c166 --- /dev/null +++ b/tests/contracts/procedure-return-1.scilla @@ -0,0 +1,31 @@ +scilla_version 0 + +library Return1 + +let one = Uint32 1 + +contract Return1() + +field f : Uint32 = Uint32 0 + +procedure return_one() -> Uint32 + a = one; + return a +end + +procedure id(x: Uint32) -> Uint32 + return x +end + +procedure add(lhs: Uint32, rhs: Uint32) -> Uint32 + s = builtin add lhs rhs; + return s +end + +transition f_add_one() + one = return_one; + f_cur <- f; + sum = add f_cur one; + sum_id = id sum; + f := sum +end diff --git a/tests/runner/Testcontracts.ml b/tests/runner/Testcontracts.ml index b91455c13..3c2eaf709 100644 --- a/tests/runner/Testcontracts.ml +++ b/tests/runner/Testcontracts.ml @@ -497,6 +497,8 @@ let contract_tests env = *) "ark-store-hashes-in-mutable-maps" >::: build_contract_tests env "ark" succ_code 1 1 []; + "procedure-return-1" + >::: build_contract_tests env "procedure-return-1" succ_code 1 1 []; ]; "these_tests_must_FAIL" >::: [ diff --git a/tests/runner/procedure-return-1/blockchain_0.json b/tests/runner/procedure-return-1/blockchain_0.json new file mode 100644 index 000000000..ae0a7dd78 --- /dev/null +++ b/tests/runner/procedure-return-1/blockchain_0.json @@ -0,0 +1,7 @@ +[ + { + "vname": "BLOCKNUMBER", + "type": "BNum", + "value": "100" + } +] diff --git a/tests/runner/procedure-return-1/blockchain_1.json b/tests/runner/procedure-return-1/blockchain_1.json new file mode 100644 index 000000000..ae0a7dd78 --- /dev/null +++ b/tests/runner/procedure-return-1/blockchain_1.json @@ -0,0 +1,7 @@ +[ + { + "vname": "BLOCKNUMBER", + "type": "BNum", + "value": "100" + } +] diff --git a/tests/runner/procedure-return-1/init.json b/tests/runner/procedure-return-1/init.json new file mode 100644 index 000000000..8ae8ec55a --- /dev/null +++ b/tests/runner/procedure-return-1/init.json @@ -0,0 +1,17 @@ +[ + { + "vname": "_scilla_version", + "type": "Uint32", + "value": "0" + }, + { + "vname": "_this_address", + "type": "ByStr20", + "value": "0xabfeccdc9012345678901234567890f777567890" + }, + { + "vname": "_creation_block", + "type": "BNum", + "value": "1" + } +] diff --git a/tests/runner/procedure-return-1/message_0.json b/tests/runner/procedure-return-1/message_0.json new file mode 100644 index 000000000..5866b38d9 --- /dev/null +++ b/tests/runner/procedure-return-1/message_0.json @@ -0,0 +1,7 @@ +{ + "_tag": "f_add_one", + "_amount": "0", + "_sender": "0xab92d4dfafd282e8a8b3c776eb9fc907d321e21a", + "params": [], + "_origin": "0xab92d4dfafd282e8a8b3c776eb9fc907d321e21a" +} diff --git a/tests/runner/procedure-return-1/message_1.json b/tests/runner/procedure-return-1/message_1.json new file mode 100644 index 000000000..5866b38d9 --- /dev/null +++ b/tests/runner/procedure-return-1/message_1.json @@ -0,0 +1,7 @@ +{ + "_tag": "f_add_one", + "_amount": "0", + "_sender": "0xab92d4dfafd282e8a8b3c776eb9fc907d321e21a", + "params": [], + "_origin": "0xab92d4dfafd282e8a8b3c776eb9fc907d321e21a" +} diff --git a/tests/runner/procedure-return-1/output_0.json b/tests/runner/procedure-return-1/output_0.json new file mode 100644 index 000000000..4a6133632 --- /dev/null +++ b/tests/runner/procedure-return-1/output_0.json @@ -0,0 +1,19 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7974", + "_accepted": "false", + "messages": [], + "states": [ + { + "vname": "_balance", + "type": "Uint128", + "value": "0" + }, + { + "vname": "f", + "type": "Uint32", + "value": "1" + } + ], + "events": [] +} diff --git a/tests/runner/procedure-return-1/output_1.json b/tests/runner/procedure-return-1/output_1.json new file mode 100644 index 000000000..e7217cca4 --- /dev/null +++ b/tests/runner/procedure-return-1/output_1.json @@ -0,0 +1,20 @@ +{ + "scilla_major_version": "0", + "gas_remaining": "7974", + "_accepted": "false", + "messages": [], + "states": [ + { + "vname": "_balance", + "type": "Uint128", + "value": "0" + }, + { + "vname": "f", + "type": "Uint32", + "value": "2" + } + ], + "events": [] +} + diff --git a/tests/runner/procedure-return-1/state_0.json b/tests/runner/procedure-return-1/state_0.json new file mode 100644 index 000000000..18bac2660 --- /dev/null +++ b/tests/runner/procedure-return-1/state_0.json @@ -0,0 +1,12 @@ +[ + { + "vname": "_balance", + "type": "Uint128", + "value": "0" + }, + { + "vname": "f", + "type": "Uint32", + "value": "0" + } +] diff --git a/tests/runner/procedure-return-1/state_1.json b/tests/runner/procedure-return-1/state_1.json new file mode 100644 index 000000000..bc017eaed --- /dev/null +++ b/tests/runner/procedure-return-1/state_1.json @@ -0,0 +1,12 @@ +[ + { + "vname": "_balance", + "type": "Uint128", + "value": "0" + }, + { + "vname": "f", + "type": "Uint32", + "value": "1" + } +] From a578852c537315364ea2a43d67d56589f3e7ecdf Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 17:14:14 +0700 Subject: [PATCH 21/41] chore(cf): Better comment --- src/base/Cashflow.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base/Cashflow.ml b/src/base/Cashflow.ml index bdc448190..4fb38b07d 100644 --- a/src/base/Cashflow.ml +++ b/src/base/Cashflow.ml @@ -1916,7 +1916,8 @@ struct ctr_tag_map, not @@ [%equal: ECFR.money_tag] (get_id_tag e) e_tag ) | CallProc (id_opt, p, args) -> - (* TODO: How does procedure call affects cash flow? *) + (* TODO: Bindings from procedure calls are not taken into account in + the cash flow analysis. *) let new_args = List.map args ~f:(fun arg -> update_id_tag arg (lookup_var_tag2 arg local_env param_env)) From 2464898bc1418d48875647a4c1f42d67fad52c5e Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 17:45:17 +0700 Subject: [PATCH 22/41] fix(dcd): False positive on `return` statement --- src/base/DeadCodeDetector.ml | 4 +-- .../good/gold/dead_code_test8.scilla.gold | 33 +++++++++++++++++-- tests/contracts/dead_code_test8.scilla | 20 ++++++++++- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/base/DeadCodeDetector.ml b/src/base/DeadCodeDetector.ml index d143d471d..df73c2a00 100644 --- a/src/base/DeadCodeDetector.ml +++ b/src/base/DeadCodeDetector.ml @@ -499,8 +499,8 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct else ( warn "Unused type cast statement to: " x ER.get_loc; (ERSet.add lv r, adts, ctrs)) - | SendMsgs v | CreateEvnt v -> (ERSet.add lv v, adts, ctrs) - | AcceptPayment | Return _ | GasStmt _ -> (lv, adts, ctrs)) + | SendMsgs v | CreateEvnt v | Return v -> (ERSet.add lv v, adts, ctrs) + | AcceptPayment | GasStmt _ -> (lv, adts, ctrs)) | _ -> (emp_erset, emp_idset, emp_idset) (** Checks for unused module's components. diff --git a/tests/checker/good/gold/dead_code_test8.scilla.gold b/tests/checker/good/gold/dead_code_test8.scilla.gold index a200c2e97..7bc64d41e 100644 --- a/tests/checker/good/gold/dead_code_test8.scilla.gold +++ b/tests/checker/good/gold/dead_code_test8.scilla.gold @@ -5,8 +5,15 @@ "vname": "Dead8", "params": [], "fields": [], - "transitions": [ { "vname": "Foo", "params": [] } ], - "procedures": [], + "transitions": [ + { "vname": "test_dead_variable1", "params": [] }, + { "vname": "test_dead_variable2", "params": [] }, + { "vname": "test_dead_variable3", "params": [] } + ], + "procedures": [ + { "vname": "pr1", "params": [] }, + { "vname": "pr2", "params": [ { "vname": "a", "type": "Bool" } ] } + ], "events": [], "ADTs": [ { @@ -49,11 +56,31 @@ ] }, "warnings": [ + { + "warning_message": "Unused local binding: dead", + "start_location": { + "file": "contracts/dead_code_test8.scilla", + "line": 27, + "column": 3 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 3 + }, + { + "warning_message": "Unused local binding: dead", + "start_location": { + "file": "contracts/dead_code_test8.scilla", + "line": 22, + "column": 3 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 3 + }, { "warning_message": "Unused bind statement to: dead", "start_location": { "file": "contracts/dead_code_test8.scilla", - "line": 9, + "line": 18, "column": 3 }, "end_location": { "file": "", "line": 0, "column": 0 }, diff --git a/tests/contracts/dead_code_test8.scilla b/tests/contracts/dead_code_test8.scilla index d91106873..720211527 100644 --- a/tests/contracts/dead_code_test8.scilla +++ b/tests/contracts/dead_code_test8.scilla @@ -4,7 +4,25 @@ library Dead8 contract Dead8 () -transition Foo () +procedure pr1() -> Bool + res = True; + return res +end + +procedure pr2(a: Bool) -> Bool + return a +end + +transition test_dead_variable1() alive = True; dead = alive end + +transition test_dead_variable2() + dead = pr1 +end + +transition test_dead_variable3() + param = True; + dead = pr2 param +end From b9906e40bd56279512bad71e1c17953a7567d230 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 17:47:59 +0700 Subject: [PATCH 23/41] fix(fmt): `make fmt` --- tests/runner/Testcontracts.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/runner/Testcontracts.ml b/tests/runner/Testcontracts.ml index 3c2eaf709..61126132f 100644 --- a/tests/runner/Testcontracts.ml +++ b/tests/runner/Testcontracts.ml @@ -498,7 +498,8 @@ let contract_tests env = "ark-store-hashes-in-mutable-maps" >::: build_contract_tests env "ark" succ_code 1 1 []; "procedure-return-1" - >::: build_contract_tests env "procedure-return-1" succ_code 1 1 []; + >::: build_contract_tests env "procedure-return-1" succ_code 1 1 + []; ]; "these_tests_must_FAIL" >::: [ From fdcbe02f7d2b8d1836f2c9fda9bbf51e116226b6 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 18:00:02 +0700 Subject: [PATCH 24/41] feat(typecheck): Prohibit procedures w/ return in `forall` --- src/base/TypeChecker.ml | 10 +++++++++- .../contracts.t/typecheck-return-2.scilla | 17 +++++++++++++++++ .../contracts.t/typecheck-return-2.scilla.gold | 4 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/typecheck/contracts.t/typecheck-return-2.scilla create mode 100644 tests/typecheck/contracts.t/typecheck-return-2.scilla.gold diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 03fec73c0..8b22c3672 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -1037,7 +1037,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct in let l_type = rr_typ lt in match lookup_proc env p with - | Some ([ arg_typ ], _) -> + | Some ([ arg_typ ], ret) when Option.is_none ret -> let%bind () = fromR_TE (* The procedure accepts an element of l. *) @@ -1050,6 +1050,14 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct @@ add_stmt_to_stmts_env_gas (TypedSyntax.Iterate (add_type_to_ident l l_type, p), rep) checked_stmts + | Some (_, ret) when Option.is_some ret -> + fail + (mk_type_error1 + ~kind: + "Procedure with return type cannot be used in forall \ + statement" + ~inst:(as_error_string p) + (SR.get_loc (get_rep p))) | _ -> fail (mk_type_error1 diff --git a/tests/typecheck/contracts.t/typecheck-return-2.scilla b/tests/typecheck/contracts.t/typecheck-return-2.scilla new file mode 100644 index 000000000..34edb6130 --- /dev/null +++ b/tests/typecheck/contracts.t/typecheck-return-2.scilla @@ -0,0 +1,17 @@ +scilla_version 0 + +library TypecheckReturn2 + +contract TypecheckReturn2() + +field l : List Uint128 = Nil {Uint128} + +procedure p(f1: Uint128) -> BNum + a = _creation_block; + return a +end + +transition p_call() + l <- l; + forall l p +end diff --git a/tests/typecheck/contracts.t/typecheck-return-2.scilla.gold b/tests/typecheck/contracts.t/typecheck-return-2.scilla.gold new file mode 100644 index 000000000..7671b960d --- /dev/null +++ b/tests/typecheck/contracts.t/typecheck-return-2.scilla.gold @@ -0,0 +1,4 @@ + +tests/typecheck/contracts.t/typecheck-return-2.scilla:16:12: error: Procedure with return type cannot be used in forall statement: p + +Gas remaining: 8000 From eb7f7d7413eab26d077c02a934658354fa4e16a3 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 17 Nov 2022 18:04:05 +0700 Subject: [PATCH 25/41] chore(gitignore): Rollback local changes --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a9086b720..15dc6df28 100644 --- a/.gitignore +++ b/.gitignore @@ -84,5 +84,7 @@ deps/cryptoutils/install/ deps/schnorr/build/ deps/schnorr/install/ -vcpkg_installed -tags +# ----------------------------------------------------------------------------- +# vcpkg build files +# ----------------------------------------------------------------------------- +vcpkg_installed/ \ No newline at end of file From 982f548057b38e17bec3d8f800741cce7f2dfd97 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 22 Nov 2022 16:35:48 +0700 Subject: [PATCH 26/41] feat(typecheck): Restrict return types to non-maps, for consistency --- src/base/TypeChecker.ml | 15 +++++++++++++++ .../contracts.t/typecheck-return-3.scilla | 12 ++++++++++++ tests/typecheck/typecheck-return-3.scilla.gold | 4 ++++ 3 files changed, 31 insertions(+) create mode 100644 tests/typecheck/contracts.t/typecheck-return-3.scilla create mode 100644 tests/typecheck/typecheck-return-3.scilla.gold diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 8b22c3672..42949ffd3 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -1114,6 +1114,21 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct | CompTrans -> is_legal_transition_parameter_type | CompProc -> is_legal_procedure_parameter_type in + (* Procedure return type has the same restrictions as parameters. *) + let%bind comp_return = + match comp_return with + | Some ret_ty -> + if param_checker ret_ty then pure @@ Some ret_ty + else + fail + (mk_type_error1 + ~kind: + (sprintf "Type cannot be used as %s return value" + component_type_string) + ~inst:(pp_typ_error ret_ty) + (SR.get_loc (get_rep comp_name))) + | None -> pure @@ None + in let%bind typed_cparams = mapM ~f:(fun (param, t) -> diff --git a/tests/typecheck/contracts.t/typecheck-return-3.scilla b/tests/typecheck/contracts.t/typecheck-return-3.scilla new file mode 100644 index 000000000..79812c7a7 --- /dev/null +++ b/tests/typecheck/contracts.t/typecheck-return-3.scilla @@ -0,0 +1,12 @@ +scilla_version 0 + +library TypecheckReturn1 + +contract TypecheckReturn1() +field f_m: Map Uint32 (Option Uint32) = Emp Uint32 (Option Uint32) + +procedure cannot_return_map() -> (Map String String) + m := f_m; + return m +end + diff --git a/tests/typecheck/typecheck-return-3.scilla.gold b/tests/typecheck/typecheck-return-3.scilla.gold new file mode 100644 index 000000000..679e20f3a --- /dev/null +++ b/tests/typecheck/typecheck-return-3.scilla.gold @@ -0,0 +1,4 @@ + +tests/typecheck/contracts.t/typecheck-return-3.scilla:8:11: error: Type cannot be used as procedure return value: Map (String) (String) + +Gas remaining: 8000 From 4eb8256a1594300f74d448039a3131f17ac8362a Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 22 Nov 2022 16:39:12 +0700 Subject: [PATCH 27/41] fix(cf): Use `NoInfo` instead `NotMoney` --- src/base/Cashflow.ml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/base/Cashflow.ml b/src/base/Cashflow.ml index 4fb38b07d..9490701d0 100644 --- a/src/base/Cashflow.ml +++ b/src/base/Cashflow.ml @@ -1876,9 +1876,7 @@ struct | AcceptPayment -> (AcceptPayment, param_env, field_env, local_env, ctr_tag_map, false) | Return i -> - let i_tag = - lub_tags NotMoney (lookup_var_tag2 i local_env param_env) - in + let i_tag = lub_tags NoInfo (lookup_var_tag2 i local_env param_env) in let new_i = update_id_tag i i_tag in let new_local_env, new_param_env = update_var_tag2 i i_tag local_env param_env From 299a34a632db25ee3d90324da81a6b0f1686cf8f Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 22 Nov 2022 16:45:33 +0700 Subject: [PATCH 28/41] fix(typechecker): Text of error --- src/base/TypeChecker.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 42949ffd3..d2da25d74 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -1022,7 +1022,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct | None -> fail (mk_type_error1 - ~kind:"Return type for procedure not found" + ~kind:"Procedure does not return a value" ~inst:(as_error_string p) (SR.get_loc (get_rep p)))) in From e110e244b2b7f6e1f6c8deac36b34f82da6b271f Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 22 Nov 2022 16:48:07 +0700 Subject: [PATCH 29/41] fix(tests): Directory structure --- tests/typecheck/{ => contracts.t}/typecheck-return-3.scilla.gold | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/typecheck/{ => contracts.t}/typecheck-return-3.scilla.gold (100%) diff --git a/tests/typecheck/typecheck-return-3.scilla.gold b/tests/typecheck/contracts.t/typecheck-return-3.scilla.gold similarity index 100% rename from tests/typecheck/typecheck-return-3.scilla.gold rename to tests/typecheck/contracts.t/typecheck-return-3.scilla.gold From 5fb80e545118929764ca9a60dd0457f004c3b1a5 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 22 Nov 2022 16:52:50 +0700 Subject: [PATCH 30/41] fix(typecheck): Error message; add test --- src/base/TypeChecker.ml | 4 ++-- .../contracts.t/typecheck-return-4.scilla | 14 ++++++++++++++ .../contracts.t/typecheck-return-4.scilla.gold | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/typecheck/contracts.t/typecheck-return-4.scilla create mode 100644 tests/typecheck/contracts.t/typecheck-return-4.scilla.gold diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index d2da25d74..09b690c35 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -1054,8 +1054,8 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct fail (mk_type_error1 ~kind: - "Procedure with return type cannot be used in forall \ - statement" + "Procedures with a return type cannot be used in forall \ + statements" ~inst:(as_error_string p) (SR.get_loc (get_rep p))) | _ -> diff --git a/tests/typecheck/contracts.t/typecheck-return-4.scilla b/tests/typecheck/contracts.t/typecheck-return-4.scilla new file mode 100644 index 000000000..87762cb76 --- /dev/null +++ b/tests/typecheck/contracts.t/typecheck-return-4.scilla @@ -0,0 +1,14 @@ +scilla_version 0 + +library TypecheckReturn4 + +contract TypecheckReturn4() + +procedure cannot_be_used_in_forall() -> BNum + r = _creation_block; + return r +end + +transition foo(l: List BNum) + forall l cannot_be_used_in_forall +end diff --git a/tests/typecheck/contracts.t/typecheck-return-4.scilla.gold b/tests/typecheck/contracts.t/typecheck-return-4.scilla.gold new file mode 100644 index 000000000..a2a713c14 --- /dev/null +++ b/tests/typecheck/contracts.t/typecheck-return-4.scilla.gold @@ -0,0 +1,4 @@ + +tests/typecheck/contracts.t/typecheck-return-4.scilla:13:12: error: Procedures with a return type cannot be used in forall statements: cannot_be_used_in_forall + +Gas remaining: 8000 From d52224517ea982811ae05aee68d55eb129d39ac6 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 22 Nov 2022 16:53:01 +0700 Subject: [PATCH 31/41] fix(test): Name of test --- tests/typecheck/contracts.t/typecheck-return-3.scilla | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/typecheck/contracts.t/typecheck-return-3.scilla b/tests/typecheck/contracts.t/typecheck-return-3.scilla index 79812c7a7..e1c423df4 100644 --- a/tests/typecheck/contracts.t/typecheck-return-3.scilla +++ b/tests/typecheck/contracts.t/typecheck-return-3.scilla @@ -1,8 +1,8 @@ scilla_version 0 -library TypecheckReturn1 +library TypecheckReturn3 -contract TypecheckReturn1() +contract TypecheckReturn3() field f_m: Map Uint32 (Option Uint32) = Emp Uint32 (Option Uint32) procedure cannot_return_map() -> (Map String String) From fa8d18f2f078a75299a9726fb579022d5d686dcd Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 28 Nov 2022 11:54:11 +0700 Subject: [PATCH 32/41] feat(sc): Forbid dead code after returns and inconsistent return in matches --- src/base/SanityChecker.ml | 79 +++++++++++++++++++ tests/checker/bad/Bad.ml | 4 + .../checker/bad/gold/return-bad1.scilla.gold | 26 ++++++ .../checker/bad/gold/return-bad2.scilla.gold | 26 ++++++ .../checker/bad/gold/return-bad3.scilla.gold | 26 ++++++ .../checker/bad/gold/return-bad4.scilla.gold | 26 ++++++ tests/checker/bad/return-bad1.scilla | 13 +++ tests/checker/bad/return-bad2.scilla | 25 ++++++ tests/checker/bad/return-bad3.scilla | 14 ++++ tests/checker/bad/return-bad4.scilla | 27 +++++++ 10 files changed, 266 insertions(+) create mode 100644 tests/checker/bad/gold/return-bad1.scilla.gold create mode 100644 tests/checker/bad/gold/return-bad2.scilla.gold create mode 100644 tests/checker/bad/gold/return-bad3.scilla.gold create mode 100644 tests/checker/bad/gold/return-bad4.scilla.gold create mode 100644 tests/checker/bad/return-bad1.scilla create mode 100644 tests/checker/bad/return-bad2.scilla create mode 100644 tests/checker/bad/return-bad3.scilla create mode 100644 tests/checker/bad/return-bad4.scilla diff --git a/src/base/SanityChecker.ml b/src/base/SanityChecker.ml index 5b5ff4969..cdb12e34f 100644 --- a/src/base/SanityChecker.ml +++ b/src/base/SanityChecker.ml @@ -877,6 +877,84 @@ struct pure () end + (* ****************************************************** *) + (* ******** Check the usage of return statements ******** *) + (* ****************************************************** *) + + module CheckReturns = struct + (** Forbids dead code after return statements and cases when a procedure + with return type doesn't return. + Returns [true] iff there is a [return] statement among [stmts]. *) + let rec check_return stmts = + (* Returns true iff there is a return statement in the given statement, + including its nesting statements. *) + let rec find_return (s, _annot) = + match s with + | Return _ -> true + | MatchStmt (_, arms) -> + List.find arms ~f:(fun (_, arm_stmts) -> + List.find arm_stmts ~f:(fun arm_stmt -> find_return arm_stmt) + |> Option.is_some) + |> Option.is_some + | _ -> false + in + match stmts with + | [] -> pure @@ false + | [ (Return _, _) ] -> pure @@ true + | (Return id, _) :: ss when not @@ List.is_empty ss -> + fail1 ~kind:"Found unreachable code after the return statement" + (ER.get_loc (get_rep id)) + | (MatchStmt (id, arms), _) :: ss -> + let match_annot = List.hd_exn stmts in + let arms_have_return = find_return match_annot in + if arms_have_return then + (* Dead code after returning matches is forbidden *) + let%bind () = + if not @@ List.is_empty ss then + let _, annot = match_annot in + fail1 + ~kind: + "Found unreachable code after the match statement whose \ + arms return" + (SR.get_loc annot) + else pure @@ () + in + (* Return statement must be in every arm *) + let%bind _ = + mapM arms ~f:(fun (_, arm_stmts) -> + let arm_has_return = + List.find arm_stmts ~f:(fun arm_stmt -> + find_return arm_stmt) + |> Option.is_some + in + if not @@ arm_has_return then + fail1 + ~kind: + "Every arm of the match statement must return because \ + one of arms returns" + (ER.get_loc (get_rep id)) + else pure @@ ()) + in + pure @@ true + else pure @@ false + | _ :: ss -> check_return ss + + let run (cmod : cmodule) = + let%bind _ = + mapM cmod.contr.ccomps ~f:(fun c -> + match c.comp_type with + | CompProc when Option.is_some c.comp_return -> + let%bind found_return = check_return c.comp_body in + if not @@ found_return then + fail1 ~kind:"Procedure with return value doesn't return" + ~inst:(as_error_string c.comp_name) + (SR.get_loc (get_rep c.comp_name)) + else pure () + | _ -> pure ()) + in + pure () + end + (* ************************************** *) (* ******** Interface to Checker ******** *) (* ************************************** *) @@ -890,6 +968,7 @@ struct let%bind () = CheckHashingBuiltinsUsage.in_libentries rlibs in let%bind () = CheckHashingBuiltinsUsage.in_cmod cmod in let%bind () = CheckUnboxing.run cmod cg rlibs in + let%bind () = CheckReturns.run cmod in DCD.dc_cmod cmod elibs; pure () diff --git a/tests/checker/bad/Bad.ml b/tests/checker/bad/Bad.ml index 9cc1ec206..42e63c119 100644 --- a/tests/checker/bad/Bad.ml +++ b/tests/checker/bad/Bad.ml @@ -139,6 +139,10 @@ module LibTests = Scilla_test.Util.DiffBasedTests (struct "import-test-lib-bad_1.scilla"; "import-test-lib-bad_2.scilla"; "import-test-lib-bad_3.scilla"; + "return-bad1.scilla"; + "return-bad2.scilla"; + "return-bad3.scilla"; + "return-bad4.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 1 diff --git a/tests/checker/bad/gold/return-bad1.scilla.gold b/tests/checker/bad/gold/return-bad1.scilla.gold new file mode 100644 index 000000000..24418a895 --- /dev/null +++ b/tests/checker/bad/gold/return-bad1.scilla.gold @@ -0,0 +1,26 @@ +{ + "gas_remaining": "8000", + "errors": [ + { + "error_message": "Procedure with return value doesn't return: no_return", + "start_location": { + "file": "checker/bad/return-bad1.scilla", + "line": 6, + "column": 11 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [ + { + "warning_message": "No transition in contract ReturnBad1 contains an accept statement\n", + "start_location": { + "file": "checker/bad/return-bad1.scilla", + "line": 3, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 1 + } + ] +} \ No newline at end of file diff --git a/tests/checker/bad/gold/return-bad2.scilla.gold b/tests/checker/bad/gold/return-bad2.scilla.gold new file mode 100644 index 000000000..ead0e9300 --- /dev/null +++ b/tests/checker/bad/gold/return-bad2.scilla.gold @@ -0,0 +1,26 @@ +{ + "gas_remaining": "8000", + "errors": [ + { + "error_message": "Every arm of the match statement must return because one of arms returns", + "start_location": { + "file": "checker/bad/return-bad2.scilla", + "line": 7, + "column": 9 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [ + { + "warning_message": "No transition in contract ReturnBad2 contains an accept statement\n", + "start_location": { + "file": "checker/bad/return-bad2.scilla", + "line": 3, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 1 + } + ] +} \ No newline at end of file diff --git a/tests/checker/bad/gold/return-bad3.scilla.gold b/tests/checker/bad/gold/return-bad3.scilla.gold new file mode 100644 index 000000000..2c32d6611 --- /dev/null +++ b/tests/checker/bad/gold/return-bad3.scilla.gold @@ -0,0 +1,26 @@ +{ + "gas_remaining": "8000", + "errors": [ + { + "error_message": "Found unreachable code after the return statement", + "start_location": { + "file": "checker/bad/return-bad3.scilla", + "line": 8, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [ + { + "warning_message": "No transition in contract ReturnBad3 contains an accept statement\n", + "start_location": { + "file": "checker/bad/return-bad3.scilla", + "line": 3, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 1 + } + ] +} \ No newline at end of file diff --git a/tests/checker/bad/gold/return-bad4.scilla.gold b/tests/checker/bad/gold/return-bad4.scilla.gold new file mode 100644 index 000000000..f1bb9c56d --- /dev/null +++ b/tests/checker/bad/gold/return-bad4.scilla.gold @@ -0,0 +1,26 @@ +{ + "gas_remaining": "8000", + "errors": [ + { + "error_message": "Found unreachable code after the match statement whose arms return", + "start_location": { + "file": "checker/bad/return-bad4.scilla", + "line": 7, + "column": 3 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [ + { + "warning_message": "No transition in contract ReturnBad4 contains an accept statement\n", + "start_location": { + "file": "checker/bad/return-bad4.scilla", + "line": 3, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 1 + } + ] +} \ No newline at end of file diff --git a/tests/checker/bad/return-bad1.scilla b/tests/checker/bad/return-bad1.scilla new file mode 100644 index 000000000..d6ccdbf36 --- /dev/null +++ b/tests/checker/bad/return-bad1.scilla @@ -0,0 +1,13 @@ +scilla_version 0 + +contract ReturnBad1() + +(* Procedure doesn't return *) +procedure no_return() -> BNum + ret = _creation_block + (* Error: no return *) +end +procedure no_return_fixed() -> BNum + ret = _creation_block; + return ret (* OK *) +end diff --git a/tests/checker/bad/return-bad2.scilla b/tests/checker/bad/return-bad2.scilla new file mode 100644 index 000000000..7001f3e24 --- /dev/null +++ b/tests/checker/bad/return-bad2.scilla @@ -0,0 +1,25 @@ +scilla_version 0 + +contract ReturnBad2() + +(* Some of match statement's arms don't return while other return *) +procedure match_no_ret(a: Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block + (* Error: no return *) + end +end +procedure match_no_ret_fixed(a: Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block; + return ret (* OK *) + end +end diff --git a/tests/checker/bad/return-bad3.scilla b/tests/checker/bad/return-bad3.scilla new file mode 100644 index 000000000..b9633a97c --- /dev/null +++ b/tests/checker/bad/return-bad3.scilla @@ -0,0 +1,14 @@ +scilla_version 0 + +contract ReturnBad3() + +(* Dead code after the return statement is forbidden *) +procedure dead_code() -> BNum + ret = _creation_block; + return ret; + dead = _creation_block (* Error *) +end +procedure dead_code_fixed() -> BNum + ret = _creation_block; + return ret +end diff --git a/tests/checker/bad/return-bad4.scilla b/tests/checker/bad/return-bad4.scilla new file mode 100644 index 000000000..20e40dc64 --- /dev/null +++ b/tests/checker/bad/return-bad4.scilla @@ -0,0 +1,27 @@ +scilla_version 0 + +contract ReturnBad4 () + +(* Dead code after the return statement in match arms is forbidden *) +procedure dead_code_match (a : Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block; + return ret + end; + dead = _creation_block (* Error *) +end +procedure dead_code_match_fixed (a : Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block; + return ret + end +end + From b60b3bb6e63fb23da3270c7cb943bf2aabf26dd5 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 28 Nov 2022 12:16:15 +0700 Subject: [PATCH 33/41] feat(sc): Improve analysis of nested matches --- src/base/SanityChecker.ml | 6 +-- tests/checker/bad/Bad.ml | 1 + .../checker/bad/gold/return-bad2.scilla.gold | 4 +- .../checker/bad/gold/return-bad5.scilla.gold | 26 +++++++++++++ tests/checker/bad/return-bad2.scilla | 7 ++-- tests/checker/bad/return-bad5.scilla | 37 +++++++++++++++++++ 6 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 tests/checker/bad/gold/return-bad5.scilla.gold create mode 100644 tests/checker/bad/return-bad5.scilla diff --git a/src/base/SanityChecker.ml b/src/base/SanityChecker.ml index cdb12e34f..008d68868 100644 --- a/src/base/SanityChecker.ml +++ b/src/base/SanityChecker.ml @@ -922,11 +922,7 @@ struct (* Return statement must be in every arm *) let%bind _ = mapM arms ~f:(fun (_, arm_stmts) -> - let arm_has_return = - List.find arm_stmts ~f:(fun arm_stmt -> - find_return arm_stmt) - |> Option.is_some - in + let%bind arm_has_return = check_return arm_stmts in if not @@ arm_has_return then fail1 ~kind: diff --git a/tests/checker/bad/Bad.ml b/tests/checker/bad/Bad.ml index 42e63c119..7f9b8505d 100644 --- a/tests/checker/bad/Bad.ml +++ b/tests/checker/bad/Bad.ml @@ -143,6 +143,7 @@ module LibTests = Scilla_test.Util.DiffBasedTests (struct "return-bad2.scilla"; "return-bad3.scilla"; "return-bad4.scilla"; + "return-bad5.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 1 diff --git a/tests/checker/bad/gold/return-bad2.scilla.gold b/tests/checker/bad/gold/return-bad2.scilla.gold index ead0e9300..e64d5c163 100644 --- a/tests/checker/bad/gold/return-bad2.scilla.gold +++ b/tests/checker/bad/gold/return-bad2.scilla.gold @@ -5,7 +5,7 @@ "error_message": "Every arm of the match statement must return because one of arms returns", "start_location": { "file": "checker/bad/return-bad2.scilla", - "line": 7, + "line": 8, "column": 9 }, "end_location": { "file": "", "line": 0, "column": 0 } @@ -16,7 +16,7 @@ "warning_message": "No transition in contract ReturnBad2 contains an accept statement\n", "start_location": { "file": "checker/bad/return-bad2.scilla", - "line": 3, + "line": 5, "column": 10 }, "end_location": { "file": "", "line": 0, "column": 0 }, diff --git a/tests/checker/bad/gold/return-bad5.scilla.gold b/tests/checker/bad/gold/return-bad5.scilla.gold new file mode 100644 index 000000000..7cee05f8a --- /dev/null +++ b/tests/checker/bad/gold/return-bad5.scilla.gold @@ -0,0 +1,26 @@ +{ + "gas_remaining": "8000", + "errors": [ + { + "error_message": "Every arm of the match statement must return because one of arms returns", + "start_location": { + "file": "checker/bad/return-bad5.scilla", + "line": 11, + "column": 11 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [ + { + "warning_message": "No transition in contract ReturnBad5 contains an accept statement\n", + "start_location": { + "file": "checker/bad/return-bad5.scilla", + "line": 3, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 1 + } + ] +} \ No newline at end of file diff --git a/tests/checker/bad/return-bad2.scilla b/tests/checker/bad/return-bad2.scilla index 7001f3e24..ff29213c1 100644 --- a/tests/checker/bad/return-bad2.scilla +++ b/tests/checker/bad/return-bad2.scilla @@ -1,8 +1,9 @@ scilla_version 0 +(* Some of match statement's arms don't return while other return *) + contract ReturnBad2() -(* Some of match statement's arms don't return while other return *) procedure match_no_ret(a: Bool) -> BNum match a with | True => @@ -10,7 +11,7 @@ procedure match_no_ret(a: Bool) -> BNum return ret | False => ret = _creation_block - (* Error: no return *) + (* Error: no return *) end end procedure match_no_ret_fixed(a: Bool) -> BNum @@ -20,6 +21,6 @@ procedure match_no_ret_fixed(a: Bool) -> BNum return ret | False => ret = _creation_block; - return ret (* OK *) + return ret (* OK *) end end diff --git a/tests/checker/bad/return-bad5.scilla b/tests/checker/bad/return-bad5.scilla new file mode 100644 index 000000000..9108de3d0 --- /dev/null +++ b/tests/checker/bad/return-bad5.scilla @@ -0,0 +1,37 @@ +scilla_version 0 + +contract ReturnBad5() + +procedure nested_match_no_ret(a: Bool, b: Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + match b with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block + (* Error: no return *) + end + end +end +procedure nested_match_no_ret_fixed(a: Bool, b: Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + match b with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block; + return ret (* OK *) + end + end +end + From ed6de9c6afa8e3dc559fe8faa7a62389f2112482 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 28 Nov 2022 12:21:38 +0700 Subject: [PATCH 34/41] feat(tests): Improve tests for matches --- tests/checker/bad/Bad.ml | 1 + .../checker/bad/gold/return-bad3.scilla.gold | 4 +- .../checker/bad/gold/return-bad6.scilla.gold | 26 ++++++++++++ tests/checker/bad/return-bad2.scilla | 4 +- tests/checker/bad/return-bad3.scilla | 3 +- tests/checker/bad/return-bad6.scilla | 41 +++++++++++++++++++ 6 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 tests/checker/bad/gold/return-bad6.scilla.gold create mode 100644 tests/checker/bad/return-bad6.scilla diff --git a/tests/checker/bad/Bad.ml b/tests/checker/bad/Bad.ml index 7f9b8505d..a8936c866 100644 --- a/tests/checker/bad/Bad.ml +++ b/tests/checker/bad/Bad.ml @@ -144,6 +144,7 @@ module LibTests = Scilla_test.Util.DiffBasedTests (struct "return-bad3.scilla"; "return-bad4.scilla"; "return-bad5.scilla"; + "return-bad6.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 1 diff --git a/tests/checker/bad/gold/return-bad3.scilla.gold b/tests/checker/bad/gold/return-bad3.scilla.gold index 2c32d6611..5308765cc 100644 --- a/tests/checker/bad/gold/return-bad3.scilla.gold +++ b/tests/checker/bad/gold/return-bad3.scilla.gold @@ -5,7 +5,7 @@ "error_message": "Found unreachable code after the return statement", "start_location": { "file": "checker/bad/return-bad3.scilla", - "line": 8, + "line": 9, "column": 10 }, "end_location": { "file": "", "line": 0, "column": 0 } @@ -16,7 +16,7 @@ "warning_message": "No transition in contract ReturnBad3 contains an accept statement\n", "start_location": { "file": "checker/bad/return-bad3.scilla", - "line": 3, + "line": 5, "column": 10 }, "end_location": { "file": "", "line": 0, "column": 0 }, diff --git a/tests/checker/bad/gold/return-bad6.scilla.gold b/tests/checker/bad/gold/return-bad6.scilla.gold new file mode 100644 index 000000000..a60360253 --- /dev/null +++ b/tests/checker/bad/gold/return-bad6.scilla.gold @@ -0,0 +1,26 @@ +{ + "gas_remaining": "8000", + "errors": [ + { + "error_message": "Found unreachable code after the return statement", + "start_location": { + "file": "checker/bad/return-bad6.scilla", + "line": 19, + "column": 14 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [ + { + "warning_message": "No transition in contract ReturnBad6 contains an accept statement\n", + "start_location": { + "file": "checker/bad/return-bad6.scilla", + "line": 5, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 1 + } + ] +} \ No newline at end of file diff --git a/tests/checker/bad/return-bad2.scilla b/tests/checker/bad/return-bad2.scilla index ff29213c1..9035b846c 100644 --- a/tests/checker/bad/return-bad2.scilla +++ b/tests/checker/bad/return-bad2.scilla @@ -11,7 +11,7 @@ procedure match_no_ret(a: Bool) -> BNum return ret | False => ret = _creation_block - (* Error: no return *) + (* Error: no return *) end end procedure match_no_ret_fixed(a: Bool) -> BNum @@ -21,6 +21,6 @@ procedure match_no_ret_fixed(a: Bool) -> BNum return ret | False => ret = _creation_block; - return ret (* OK *) + return ret (* OK *) end end diff --git a/tests/checker/bad/return-bad3.scilla b/tests/checker/bad/return-bad3.scilla index b9633a97c..1302df16f 100644 --- a/tests/checker/bad/return-bad3.scilla +++ b/tests/checker/bad/return-bad3.scilla @@ -1,8 +1,9 @@ scilla_version 0 +(* Dead code after the return statement is forbidden *) + contract ReturnBad3() -(* Dead code after the return statement is forbidden *) procedure dead_code() -> BNum ret = _creation_block; return ret; diff --git a/tests/checker/bad/return-bad6.scilla b/tests/checker/bad/return-bad6.scilla new file mode 100644 index 000000000..3cad4e3c7 --- /dev/null +++ b/tests/checker/bad/return-bad6.scilla @@ -0,0 +1,41 @@ +scilla_version 0 + +(* Dead code after the return statement in match arms is forbidden *) + +contract ReturnBad6() + +procedure dead_code_in_match(a: Bool, b: Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + match b with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block; + return ret; + dead = _creation_block (* Error *) + end + end +end +procedure dead_code_in_match_fixed(a: Bool, b: Bool) -> BNum + match a with + | True => + ret = _creation_block; + return ret + | False => + match b with + | True => + ret = _creation_block; + return ret + | False => + ret = _creation_block; + return ret + (* Fixed *) + end + end +end + From d17e64283c31be2ba7164c673054bcef2d008d95 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 28 Nov 2022 12:51:25 +0700 Subject: [PATCH 35/41] feat(tests): Improve dynamic behavior tests --- tests/contracts/procedure-return-1.scilla | 28 +++++++++++++++---- tests/runner/procedure-return-1/output_0.json | 2 +- tests/runner/procedure-return-1/output_1.json | 4 +-- tests/runner/procedure-return-1/state_0.json | 2 +- tests/runner/procedure-return-1/state_1.json | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/tests/contracts/procedure-return-1.scilla b/tests/contracts/procedure-return-1.scilla index 97f62c166..32e778037 100644 --- a/tests/contracts/procedure-return-1.scilla +++ b/tests/contracts/procedure-return-1.scilla @@ -2,23 +2,38 @@ scilla_version 0 library Return1 -let one = Uint32 1 +let one = Int32 1 contract Return1() -field f : Uint32 = Uint32 0 +field f : Int32 = Int32 0 -procedure return_one() -> Uint32 +procedure return_one() -> Int32 a = one; return a end -procedure id(x: Uint32) -> Uint32 +procedure forbid_negative_f() + f <- f; + one = return_one; + zero = builtin sub one one; + is_neg = builtin lt f zero; + match is_neg with + | True => + e = { _exception : "Negative f" }; + throw e + | False => + end +end + +procedure id(x: Int32) -> Int32 + forbid_negative_f; return x end -procedure add(lhs: Uint32, rhs: Uint32) -> Uint32 - s = builtin add lhs rhs; +procedure add(lhs: Int32, rhs: Int32) -> Int32 + lhs_ = id lhs; + s = builtin add lhs_ rhs; return s end @@ -29,3 +44,4 @@ transition f_add_one() sum_id = id sum; f := sum end + diff --git a/tests/runner/procedure-return-1/output_0.json b/tests/runner/procedure-return-1/output_0.json index 4a6133632..2f54e40ee 100644 --- a/tests/runner/procedure-return-1/output_0.json +++ b/tests/runner/procedure-return-1/output_0.json @@ -11,7 +11,7 @@ }, { "vname": "f", - "type": "Uint32", + "type": "Int32", "value": "1" } ], diff --git a/tests/runner/procedure-return-1/output_1.json b/tests/runner/procedure-return-1/output_1.json index e7217cca4..f21184b5e 100644 --- a/tests/runner/procedure-return-1/output_1.json +++ b/tests/runner/procedure-return-1/output_1.json @@ -1,6 +1,6 @@ { "scilla_major_version": "0", - "gas_remaining": "7974", + "gas_remaining": "7968", "_accepted": "false", "messages": [], "states": [ @@ -11,7 +11,7 @@ }, { "vname": "f", - "type": "Uint32", + "type": "Int32", "value": "2" } ], diff --git a/tests/runner/procedure-return-1/state_0.json b/tests/runner/procedure-return-1/state_0.json index 18bac2660..6b7b2e334 100644 --- a/tests/runner/procedure-return-1/state_0.json +++ b/tests/runner/procedure-return-1/state_0.json @@ -6,7 +6,7 @@ }, { "vname": "f", - "type": "Uint32", + "type": "Int32", "value": "0" } ] diff --git a/tests/runner/procedure-return-1/state_1.json b/tests/runner/procedure-return-1/state_1.json index bc017eaed..43393682e 100644 --- a/tests/runner/procedure-return-1/state_1.json +++ b/tests/runner/procedure-return-1/state_1.json @@ -6,7 +6,7 @@ }, { "vname": "f", - "type": "Uint32", + "type": "Int32", "value": "1" } ] From 224a0e38ef886497c92e7101298db27aca0655aa Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 8 Dec 2022 18:58:08 +0700 Subject: [PATCH 36/41] feat(syntax): Use `_return := x` in concrete syntax --- src/base/ParserFaults.messages | 261 +++++++++--------- src/base/ScillaLexer.mll | 1 - src/base/ScillaParser.mly | 8 +- src/formatter/Formatter.ml | 3 +- tests/base/parser/bad/Bad.ml | 1 + .../base/parser/bad/gold/return-1.scilla.gold | 14 + tests/base/parser/bad/return-1.scilla | 10 + .../checker/bad/gold/return-bad3.scilla.gold | 2 +- .../checker/bad/gold/return-bad6.scilla.gold | 2 +- tests/checker/bad/return-bad1.scilla | 2 +- tests/checker/bad/return-bad2.scilla | 6 +- tests/checker/bad/return-bad3.scilla | 4 +- tests/checker/bad/return-bad4.scilla | 8 +- tests/checker/bad/return-bad5.scilla | 10 +- tests/checker/bad/return-bad6.scilla | 12 +- tests/contracts/dead_code_test8.scilla | 4 +- ...cedure-return-1.scilla => return-1.scilla} | 6 +- .../procedure-return-1.scilla | 6 +- .../look_and_feel/return.t/return.scilla | 6 +- tests/formatter/look_and_feel/return.t/run.t | 6 +- tests/runner/Testcontracts.ml | 4 +- .../blockchain_0.json | 0 .../blockchain_1.json | 0 .../init.json | 0 .../message_0.json | 0 .../message_1.json | 0 .../output_0.json | 0 .../output_1.json | 0 .../state_0.json | 0 .../state_1.json | 0 30 files changed, 197 insertions(+), 179 deletions(-) create mode 100644 tests/base/parser/bad/gold/return-1.scilla.gold create mode 100644 tests/base/parser/bad/return-1.scilla rename tests/contracts/{procedure-return-1.scilla => return-1.scilla} (93%) rename tests/runner/{procedure-return-1 => return-1}/blockchain_0.json (100%) rename tests/runner/{procedure-return-1 => return-1}/blockchain_1.json (100%) rename tests/runner/{procedure-return-1 => return-1}/init.json (100%) rename tests/runner/{procedure-return-1 => return-1}/message_0.json (100%) rename tests/runner/{procedure-return-1 => return-1}/message_1.json (100%) rename tests/runner/{procedure-return-1 => return-1}/output_0.json (100%) rename tests/runner/{procedure-return-1 => return-1}/output_1.json (100%) rename tests/runner/{procedure-return-1 => return-1}/state_0.json (100%) rename tests/runner/{procedure-return-1 => return-1}/state_1.json (100%) diff --git a/src/base/ParserFaults.messages b/src/base/ParserFaults.messages index ca18b1a80..477e96910 100644 --- a/src/base/ParserFaults.messages +++ b/src/base/ParserFaults.messages @@ -10,6 +10,9 @@ #@ WARNING: #@ The following comment has been copied from "src/base/ParserFaults.messages". #@ It may need to be proofread, updated, moved, or removed. +#@ WARNING: +#@ The following comment has been copied from "src/base/ParserFaults.messages". +#@ It may need to be proofread, updated, moved, or removed. # This file is part of scilla. # # Copyright (c) 2018 - present Zilliqa Research Pvt. Ltd. @@ -40,7 +43,7 @@ type_term: CID LPAREN TID WITH ## ## Ends in an error in state: 74. ## -## targ -> LPAREN typ . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> LPAREN typ . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## typ -> typ . TARROW typ [ TARROW RPAREN ] ## ## The known suffix of the stack is as follows: @@ -54,7 +57,7 @@ type_term: CID LPAREN WITH ## ## Ends in an error in state: 73. ## -## targ -> LPAREN . typ RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> LPAREN . typ RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -67,7 +70,7 @@ type_term: CID MAP WITH ## ## Ends in an error in state: 20. ## -## targ -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -80,7 +83,7 @@ type_term: CID PERIOD WITH ## ## Ends in an error in state: 57. ## -## scid -> CID PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID PERIOD @@ -93,7 +96,7 @@ type_term: CID TID WITH ## ## Ends in an error in state: 77. ## -## list(targ) -> targ . list(targ) [ THROW TARROW SEND RPAREN RETURN RBRACE MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## list(targ) -> targ . list(targ) [ THROW TARROW SEND RPAREN RBRACE MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## targ @@ -106,8 +109,8 @@ type_term: FORALL TID PERIOD TID WITH ## ## Ends in an error in state: 69. ## -## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] -## typ -> FORALL TID PERIOD typ . [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL TID PERIOD typ . [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID PERIOD typ @@ -120,7 +123,7 @@ type_term: FORALL TID PERIOD WITH ## ## Ends in an error in state: 68. ## -## typ -> FORALL TID PERIOD . typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL TID PERIOD . typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID PERIOD @@ -133,7 +136,7 @@ type_term: FORALL TID WITH ## ## Ends in an error in state: 67. ## -## typ -> FORALL TID . PERIOD typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL TID . PERIOD typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID @@ -146,7 +149,7 @@ type_term: FORALL WITH ## ## Ends in an error in state: 66. ## -## typ -> FORALL . TID PERIOD typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL . TID PERIOD typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL @@ -160,7 +163,7 @@ type_term: LPAREN TID WITH ## Ends in an error in state: 82. ## ## typ -> typ . TARROW typ [ TARROW RPAREN ] -## typ -> LPAREN typ . RPAREN [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> LPAREN typ . RPAREN [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN typ @@ -173,7 +176,7 @@ type_term: LPAREN WITH ## ## Ends in an error in state: 65. ## -## typ -> LPAREN . typ RPAREN [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> LPAREN . typ RPAREN [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -201,7 +204,7 @@ type_term: MAP CID LPAREN MAP WITH ## ## Ends in an error in state: 39. ## -## t_map_value -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -214,7 +217,7 @@ type_term: MAP CID LPAREN WITH ## ## Ends in an error in state: 41. ## -## t_map_value -> LPAREN . t_map_value_allow_targs RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> LPAREN . t_map_value_allow_targs RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -227,13 +230,13 @@ type_term: MAP CID UNDERSCORE ## ## Ends in an error in state: 25. ## -## address_typ -> CID . WITH END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## scid -> CID . [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## scid -> CID . PERIOD CID [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID . [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID . PERIOD CID [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID @@ -260,7 +263,7 @@ type_term: MAP WITH ## ## Ends in an error in state: 37. ## -## typ -> MAP . t_map_key t_map_value [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> MAP . t_map_key t_map_value [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -273,8 +276,8 @@ type_term: TID TARROW TID WITH ## ## Ends in an error in state: 71. ## -## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] -## typ -> typ TARROW typ . [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ TARROW typ . [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## typ TARROW typ @@ -287,7 +290,7 @@ type_term: TID TARROW WITH ## ## Ends in an error in state: 70. ## -## typ -> typ TARROW . typ [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ TARROW . typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## typ TARROW @@ -300,11 +303,11 @@ type_term: CID WITH EOF ## ## Ends in an error in state: 26. ## -## address_typ -> CID WITH . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH @@ -315,7 +318,7 @@ Invalid or incomplete type. type_term: TID WITH ## -## Ends in an error in state: 375. +## Ends in an error in state: 373. ## ## typ -> typ . TARROW typ [ TARROW EOF ] ## type_term -> typ . EOF [ # ] @@ -329,7 +332,7 @@ This is an invalid type term, the ADT constructor arguments are likely incorrect type_term: WITH ## -## Ends in an error in state: 373. +## Ends in an error in state: 371. ## ## type_term' -> . type_term [ # ] ## @@ -342,7 +345,7 @@ This is an invalid type term. stmts_term: ACCEPT WITH ## -## Ends in an error in state: 321. +## Ends in an error in state: 319. ## ## separated_nonempty_list(SEMICOLON,stmt) -> stmt . [ EOF END BAR ] ## separated_nonempty_list(SEMICOLON,stmt) -> stmt . SEMICOLON separated_nonempty_list(SEMICOLON,stmt) [ EOF END BAR ] @@ -357,7 +360,7 @@ This is likely an improperly terminated statement (lacking the semicolon). stmts_term: CID WITH ## -## Ends in an error in state: 325. +## Ends in an error in state: 323. ## ## stmt -> component_id . list(sident) [ SEMICOLON EOF END BAR ] ## @@ -370,7 +373,7 @@ This is an invalid statements term. stmts_term: DELETE ID WITH ## -## Ends in an error in state: 318. +## Ends in an error in state: 316. ## ## stmt -> DELETE ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -383,7 +386,7 @@ This is an invalid delete statement, it lacks the keys to delete. stmts_term: DELETE WITH ## -## Ends in an error in state: 317. +## Ends in an error in state: 315. ## ## stmt -> DELETE . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -396,7 +399,7 @@ This is an invalid delete statement, it lacks a map to delete from. stmts_term: EVENT WITH ## -## Ends in an error in state: 315. +## Ends in an error in state: 313. ## ## stmt -> EVENT . sid [ SEMICOLON EOF END BAR ] ## @@ -409,7 +412,7 @@ This is an invalid event statement, it lacks a separated identifier for the even stmts_term: ID ASSIGN WITH ## -## Ends in an error in state: 307. +## Ends in an error in state: 305. ## ## stmt -> ID ASSIGN . sid [ SEMICOLON EOF END BAR ] ## @@ -422,7 +425,7 @@ This is an invalid assign statement, it lacks a separated identifier. stmts_term: ID FETCH AND WITH ## -## Ends in an error in state: 274. +## Ends in an error in state: 272. ## ## remote_fetch_stmt -> ID FETCH AND . ID PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND . SPID PERIOD SPID [ SEMICOLON EOF END BAR ] @@ -441,7 +444,7 @@ This is an invalid bind and statement. The parser expects a capital identifier a stmts_term: ID FETCH EXISTS ID WITH ## -## Ends in an error in state: 272. +## Ends in an error in state: 270. ## ## stmt -> ID FETCH EXISTS ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -454,7 +457,7 @@ This is an invalid existence bind statement. It lacks a non-empty list of access stmts_term: ID FETCH EXISTS WITH ## -## Ends in an error in state: 271. +## Ends in an error in state: 269. ## ## stmt -> ID FETCH EXISTS . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -467,7 +470,7 @@ This is an invalid existence bind statement. It lacks a map to check existence o stmts_term: ID FETCH ID WITH ## -## Ends in an error in state: 267. +## Ends in an error in state: 265. ## ## sid -> ID . [ SEMICOLON EOF END BAR ] ## stmt -> ID FETCH ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] @@ -481,7 +484,7 @@ This is an invalid bind statement, it is lacking a non empty list of map accesse stmts_term: ID FETCH WITH ## -## Ends in an error in state: 266. +## Ends in an error in state: 264. ## ## remote_fetch_stmt -> ID FETCH . AND ID PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH . AND SPID PERIOD SPID [ SEMICOLON EOF END BAR ] @@ -503,7 +506,7 @@ This is an invalid bind statement, the bind can be followed by '&', 'exists' or stmts_term: ID EQ WITH ## -## Ends in an error in state: 305. +## Ends in an error in state: 303. ## ## stmt -> ID EQ . exp [ SEMICOLON EOF END BAR ] ## @@ -516,7 +519,7 @@ This is an invalid equal statement, it is lacking a valid expression on the righ stmts_term: ID LSQB SPID RSQB ASSIGN WITH ## -## Ends in an error in state: 310. +## Ends in an error in state: 308. ## ## stmt -> ID nonempty_list(map_access) ASSIGN . sid [ SEMICOLON EOF END BAR ] ## @@ -529,7 +532,7 @@ The map key must be assigned to some separated identifier. stmts_term: ID LSQB SPID RSQB SEMICOLON ## -## Ends in an error in state: 309. +## Ends in an error in state: 307. ## ## stmt -> ID nonempty_list(map_access) . ASSIGN sid [ SEMICOLON EOF END BAR ] ## @@ -540,7 +543,7 @@ stmts_term: ID LSQB SPID RSQB SEMICOLON ## This implies that, although the LR(1) items shown above provide an ## accurate view of the past (what has been recognized so far), they ## may provide an INCOMPLETE view of the future (what was expected next). -## In state 269, spurious reduction of production nonempty_list(map_access) -> map_access +## In state 267, spurious reduction of production nonempty_list(map_access) -> map_access ## # see tests/parser/bad/stmts_t-id-lsqb-spid-rsqb-semicolon.scilla @@ -548,7 +551,7 @@ This is likely an invalid map assign statement, it lacks the assign. stmts_term: ID LSQB SPID RSQB WITH ## -## Ends in an error in state: 269. +## Ends in an error in state: 267. ## ## nonempty_list(map_access) -> map_access . [ SEMICOLON EOF END BAR ASSIGN ] ## nonempty_list(map_access) -> map_access . nonempty_list(map_access) [ SEMICOLON EOF END BAR ASSIGN ] @@ -562,7 +565,7 @@ This is an invalid statements term. A possible continuation may be assigning a m stmts_term: ID LSQB SPID WITH ## -## Ends in an error in state: 264. +## Ends in an error in state: 262. ## ## map_access -> LSQB sident . RSQB [ SEMICOLON LSQB EOF END BAR ASSIGN ] ## @@ -575,7 +578,7 @@ This is an invalid statements term. A possible continuation may be accessing a k stmts_term: ID LSQB WITH ## -## Ends in an error in state: 263. +## Ends in an error in state: 261. ## ## map_access -> LSQB . sident RSQB [ SEMICOLON LSQB EOF END BAR ASSIGN ] ## @@ -601,7 +604,7 @@ This is an invalid statements term, likely a bad procedure call with faulty argu stmts_term: ID WITH ## -## Ends in an error in state: 262. +## Ends in an error in state: 260. ## ## component_id -> ID . [ SPID SEMICOLON ID EOF END CID BAR ] ## remote_fetch_stmt -> ID . FETCH AND ID PERIOD sident [ SEMICOLON EOF END BAR ] @@ -627,7 +630,7 @@ This is an invalid statements term. Scilla expects to do something with the iden stmts_term: MATCH SPID UNDERSCORE ## -## Ends in an error in state: 257. +## Ends in an error in state: 255. ## ## stmt -> MATCH sid . WITH list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -640,7 +643,7 @@ This is an invalid match statement, 'with' is expected after what is specified t stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW ACCEPT EOF ## -## Ends in an error in state: 329. +## Ends in an error in state: 327. ## ## list(stmt_pm_clause) -> stmt_pm_clause . list(stmt_pm_clause) [ END ] ## @@ -651,9 +654,9 @@ stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW ACCEPT EOF ## This implies that, although the LR(1) items shown above provide an ## accurate view of the past (what has been recognized so far), they ## may provide an INCOMPLETE view of the future (what was expected next). -## In state 321, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 327, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 328, spurious reduction of production stmt_pm_clause -> BAR pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 319, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 325, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 326, spurious reduction of production stmt_pm_clause -> BAR pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) ## # see tests/parser/bad/stmts_t-match-spid-with-bar-underscore-arrow-accept-eof.scilla @@ -661,7 +664,7 @@ When the match statement is finished, the parser expects 'end'. stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW WITH ## -## Ends in an error in state: 261. +## Ends in an error in state: 259. ## ## stmt_pm_clause -> BAR pattern ARROW . loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -674,7 +677,7 @@ This is an invalid statements term. In the match expression, after an arrow the stmts_term: MATCH SPID WITH BAR UNDERSCORE WITH ## -## Ends in an error in state: 260. +## Ends in an error in state: 258. ## ## stmt_pm_clause -> BAR pattern . ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -687,7 +690,7 @@ This is an invalid statements term. In the match expression, after a pattern is stmts_term: MATCH SPID WITH BAR WITH ## -## Ends in an error in state: 259. +## Ends in an error in state: 257. ## ## stmt_pm_clause -> BAR . pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -700,7 +703,7 @@ In the match statement there is a malformed pattern. stmts_term: MATCH SPID WITH WITH ## -## Ends in an error in state: 258. +## Ends in an error in state: 256. ## ## stmt -> MATCH sid WITH . list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -713,7 +716,7 @@ There is a malformed pattern matching clause, the bar is likely missing. stmts_term: MATCH WITH ## -## Ends in an error in state: 256. +## Ends in an error in state: 254. ## ## stmt -> MATCH . sid WITH list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -765,7 +768,7 @@ It is expected to send to a separated identifier. stmts_term: THROW END ## -## Ends in an error in state: 371. +## Ends in an error in state: 369. ## ## stmts_term -> stmts . EOF [ # ] ## @@ -778,9 +781,9 @@ stmts_term: THROW END ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 249, spurious reduction of production option(sid) -> ## In state 251, spurious reduction of production stmt -> THROW option(sid) -## In state 321, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 327, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 335, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 319, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 325, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 333, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) ## # special case, only via stmts_term entry point should never happen # throw itself is a valid statement term and a procedure or transition @@ -790,7 +793,7 @@ This is an invalid statements term, bad throw. stmts_term: THROW SEMICOLON WITH ## -## Ends in an error in state: 322. +## Ends in an error in state: 320. ## ## separated_nonempty_list(SEMICOLON,stmt) -> stmt SEMICOLON . separated_nonempty_list(SEMICOLON,stmt) [ EOF END BAR ] ## @@ -818,7 +821,7 @@ This throw does not throw a valid exception or is not properly terminated. stmts_term: WITH ## -## Ends in an error in state: 369. +## Ends in an error in state: 367. ## ## stmts_term' -> . stmts_term [ # ] ## @@ -871,7 +874,7 @@ To import another library mention the new library name directly after the previo lmodule: SCILLA_VERSION NUMLIT IMPORT CONTRACT ## -## Ends in an error in state: 365. +## Ends in an error in state: 363. ## ## lmodule -> SCILLA_VERSION NUMLIT imports . library EOF [ # ] ## @@ -904,7 +907,7 @@ If import is mentioned there must be one or more imported libraries with capital lmodule: SCILLA_VERSION NUMLIT LIBRARY CID CONTRACT ## -## Ends in an error in state: 366. +## Ends in an error in state: 364. ## ## lmodule -> SCILLA_VERSION NUMLIT imports library . EOF [ # ] ## @@ -1123,7 +1126,7 @@ This is an invalid library module because it lacks a capital identifier for a na lmodule: SCILLA_VERSION NUMLIT WITH ## -## Ends in an error in state: 364. +## Ends in an error in state: 362. ## ## lmodule -> SCILLA_VERSION NUMLIT . imports library EOF [ # ] ## @@ -1136,7 +1139,7 @@ This is an invalid library module, Scilla version must be followed by 'library' lmodule: WITH ## -## Ends in an error in state: 362. +## Ends in an error in state: 360. ## ## lmodule' -> . lmodule [ # ] ## @@ -1746,7 +1749,7 @@ This is an invalid expression. If it is an application of a function, it is nece exp_term: STRING WITH ## -## Ends in an error in state: 360. +## Ends in an error in state: 358. ## ## exp_term -> exp . EOF [ # ] ## @@ -1798,7 +1801,7 @@ Type functions expect a type id (e.g. 'A). exp_term: WITH ## -## Ends in an error in state: 358. +## Ends in an error in state: 356. ## ## exp_term' -> . exp_term [ # ] ## @@ -1839,7 +1842,7 @@ For a mutable field declaration, the parser expects a valid lower case beginning cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE ID LPAREN RPAREN WITH ## -## Ends in an error in state: 339. +## Ends in an error in state: 337. ## ## procedure -> PROCEDURE component_id component_params . option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## @@ -1852,7 +1855,7 @@ In the transition body the parser expects a list of semi-colon separated stateme cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE ID WITH ## -## Ends in an error in state: 338. +## Ends in an error in state: 336. ## ## procedure -> PROCEDURE component_id . component_params option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## @@ -1866,7 +1869,7 @@ be a left parenthesis. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE WITH ## -## Ends in an error in state: 337. +## Ends in an error in state: 335. ## ## procedure -> PROCEDURE . component_id component_params option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## @@ -1879,7 +1882,7 @@ A procedure requires a valid name. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN RPAREN END WITH ## -## Ends in an error in state: 348. +## Ends in an error in state: 346. ## ## list(component) -> component . list(component) [ EOF ] ## @@ -1892,7 +1895,7 @@ Following a transition definition, the parser expects a transition or a procedur cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN RPAREN THROW BAR ## -## Ends in an error in state: 333. +## Ends in an error in state: 331. ## ## component_body -> stmts . END [ TRANSITION PROCEDURE EOF ] ## @@ -1905,9 +1908,9 @@ cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN R ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 249, spurious reduction of production option(sid) -> ## In state 251, spurious reduction of production stmt -> THROW option(sid) -## In state 321, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 327, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 335, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 319, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 325, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 333, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) ## # see tests/parser/cmodule-transition-id-lparen-rparen-throw-bar.scilla @@ -1930,7 +1933,7 @@ cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN W ## ## Ends in an error in state: 245. ## -## component_params -> LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN [ THROW TARROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## component_params -> LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN [ THROW TARROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -2038,7 +2041,7 @@ cmodule: SCILLA_VERSION NUMLIT LIBRARY CID EOF ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 12, spurious reduction of production list(libentry) -> ## In state 223, spurious reduction of production library -> LIBRARY CID list(libentry) -## In state 356, spurious reduction of production option(library) -> library +## In state 354, spurious reduction of production option(library) -> library ## # see tests/parser/bad/cmodule-version-number-library-name @@ -2126,7 +2129,7 @@ type_term: CID MAP CID TYPE ## ## Ends in an error in state: 107. ## -## targ -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2145,7 +2148,7 @@ type_term: CID TYPE ## ## Ends in an error in state: 72. ## -## typ -> scid . list(targ) [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> scid . list(targ) [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## scid @@ -2229,7 +2232,7 @@ type_term: CID WITH CONTRACT LPAREN RPAREN WITH ## ## Ends in an error in state: 92. ## -## address_typ -> CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN @@ -2241,7 +2244,7 @@ type_term: CID WITH CONTRACT LPAREN WITH ## ## Ends in an error in state: 33. ## -## address_typ -> CID WITH CONTRACT LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT LPAREN @@ -2253,8 +2256,8 @@ type_term: CID WITH CONTRACT WITH ## ## Ends in an error in state: 32. ## -## address_typ -> CID WITH CONTRACT . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH CONTRACT . LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT . LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT @@ -2266,7 +2269,7 @@ type_term: HEXLIT WITH ## ## Ends in an error in state: 22. ## -## scid -> HEXLIT . PERIOD CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> HEXLIT . PERIOD CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## HEXLIT @@ -2278,7 +2281,7 @@ type_term: MAP CID MAP CID TYPE ## ## Ends in an error in state: 40. ## -## t_map_value -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2297,7 +2300,7 @@ type_term: MAP CID TYPE ## ## Ends in an error in state: 38. ## -## typ -> MAP t_map_key . t_map_value [ THROW TARROW SEND RPAREN RETURN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> MAP t_map_key . t_map_value [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2344,7 +2347,7 @@ Ends in an error in state: 99. stmts_term: FORALL SPID WITH ## -## Ends in an error in state: 313. +## Ends in an error in state: 311. ## ## stmt -> FORALL sident . component_id [ SEMICOLON EOF END BAR ] ## @@ -2356,7 +2359,7 @@ Ends in an error in state: 297. stmts_term: FORALL WITH ## -## Ends in an error in state: 312. +## Ends in an error in state: 310. ## ## stmt -> FORALL . sident component_id [ SEMICOLON EOF END BAR ] ## @@ -2368,7 +2371,7 @@ Ends in an error in state: 296. stmts_term: ID FETCH AND CID PERIOD ID WITH ## -## Ends in an error in state: 300. +## Ends in an error in state: 298. ## ## remote_fetch_stmt -> ID FETCH AND sident . AS address_typ [ SEMICOLON EOF END BAR ] ## @@ -2380,7 +2383,7 @@ Remote reads are not allowed to use namespaces. stmts_term: ID FETCH AND CID WITH ## -## Ends in an error in state: 291. +## Ends in an error in state: 289. ## ## sident -> CID . PERIOD ID [ AS ] ## stmt -> ID FETCH AND CID . option(bcfetch_args) [ SEMICOLON EOF END BAR ] @@ -2393,7 +2396,7 @@ Ends in an error in state: 283. stmts_term: ID FETCH AND EXISTS ID PERIOD ID WITH ## -## Ends in an error in state: 289. +## Ends in an error in state: 287. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID PERIOD ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2405,7 +2408,7 @@ Ends in an error in state: 281. stmts_term: ID FETCH AND EXISTS ID PERIOD WITH ## -## Ends in an error in state: 288. +## Ends in an error in state: 286. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID PERIOD . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2417,7 +2420,7 @@ Ends in an error in state: 280. stmts_term: ID FETCH AND EXISTS ID WITH ## -## Ends in an error in state: 287. +## Ends in an error in state: 285. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID . PERIOD ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2429,7 +2432,7 @@ Ends in an error in state: 279. stmts_term: ID FETCH AND EXISTS WITH ## -## Ends in an error in state: 286. +## Ends in an error in state: 284. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS . ID PERIOD ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2441,7 +2444,7 @@ Ends in an error in state: 278. stmts_term: ID FETCH AND ID PERIOD ID WITH ## -## Ends in an error in state: 283. +## Ends in an error in state: 281. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## sident -> ID . [ SEMICOLON EOF END BAR ] @@ -2454,7 +2457,7 @@ Ends in an error in state: 275. stmts_term: ID FETCH AND ID PERIOD LPAREN SPID WITH ## -## Ends in an error in state: 281. +## Ends in an error in state: 279. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD LPAREN sident . RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2466,7 +2469,7 @@ Ends in an error in state: 273. stmts_term: ID FETCH AND ID PERIOD LPAREN WITH ## -## Ends in an error in state: 280. +## Ends in an error in state: 278. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD LPAREN . sident RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2478,7 +2481,7 @@ Ends in an error in state: 272. stmts_term: ID FETCH AND ID PERIOD WITH ## -## Ends in an error in state: 279. +## Ends in an error in state: 277. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD . sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND ID PERIOD . LPAREN sident RPAREN [ SEMICOLON EOF END BAR ] @@ -2492,7 +2495,7 @@ Ends in an error in state: 271. stmts_term: ID FETCH AND ID WITH ## -## Ends in an error in state: 278. +## Ends in an error in state: 276. ## ## remote_fetch_stmt -> ID FETCH AND ID . PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND ID . PERIOD LPAREN sident RPAREN [ SEMICOLON EOF END BAR ] @@ -2507,7 +2510,7 @@ Either blockchain state variable or remote field read expected. stmts_term: ID FETCH AND SPID AS CID UNDERSCORE ## -## Ends in an error in state: 302. +## Ends in an error in state: 300. ## ## address_typ -> CID . WITH END [ SEMICOLON EOF END BAR ] ## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ SEMICOLON EOF END BAR ] @@ -2523,7 +2526,7 @@ Casts to non-ByStr20 types are not allowed. stmts_term: ID FETCH AND SPID AS WITH ## -## Ends in an error in state: 301. +## Ends in an error in state: 299. ## ## remote_fetch_stmt -> ID FETCH AND sident AS . address_typ [ SEMICOLON EOF END BAR ] ## @@ -2535,7 +2538,7 @@ Ends in an error in state: 285. stmts_term: ID FETCH AND SPID PERIOD WITH ## -## Ends in an error in state: 276. +## Ends in an error in state: 274. ## ## remote_fetch_stmt -> ID FETCH AND SPID PERIOD . SPID [ SEMICOLON EOF END BAR ] ## @@ -2547,7 +2550,7 @@ Ends in an error in state: 268. stmts_term: ID FETCH AND SPID WITH ## -## Ends in an error in state: 275. +## Ends in an error in state: 273. ## ## remote_fetch_stmt -> ID FETCH AND SPID . PERIOD SPID [ SEMICOLON EOF END BAR ] ## sident -> SPID . [ AS ] @@ -2560,7 +2563,7 @@ Ends in an error in state: 267. lmodule: SCILLA_VERSION WITH ## -## Ends in an error in state: 363. +## Ends in an error in state: 361. ## ## lmodule -> SCILLA_VERSION . NUMLIT imports library EOF [ # ] ## @@ -2624,7 +2627,7 @@ exp_term: HEXLIT PERIOD WITH ## ## Ends in an error in state: 23. ## -## scid -> HEXLIT PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET LBRACE IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> HEXLIT PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET LBRACE IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## HEXLIT PERIOD @@ -2667,7 +2670,7 @@ match-expression is probably missing `end` keyword. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN FIELD ID COLON TID EQ STRING WITH ## -## Ends in an error in state: 350. +## Ends in an error in state: 348. ## ## list(field) -> field . list(field) [ TRANSITION PROCEDURE EOF ] ## @@ -2890,7 +2893,7 @@ type_term: MAP CID LPAREN MAP CID CID TYPE ## ## Ends in an error in state: 42. ## -## t_map_value -> LPAREN t_map_value_allow_targs . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> LPAREN t_map_value_allow_targs . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN t_map_value_allow_targs @@ -2931,7 +2934,7 @@ type_term: CID WITH SPID WITH ## ## Ends in an error in state: 27. ## -## address_typ -> CID WITH SPID . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH SPID . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH SPID @@ -2943,7 +2946,7 @@ type_term: CID WITH LIBRARY WITH ## ## Ends in an error in state: 29. ## -## address_typ -> CID WITH LIBRARY . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RETURN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH LIBRARY . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH LIBRARY @@ -2953,7 +2956,7 @@ Ends in an error in state: 29. Please report your example at https://github.com/ stmts_term: ID FETCH AND CID LPAREN WITH ## -## Ends in an error in state: 292. +## Ends in an error in state: 290. ## ## bcfetch_args -> LPAREN . separated_nonempty_list(COMMA,sident) RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2965,7 +2968,7 @@ Ends in an error in state: 290. Please report your example at https://github.com stmts_term: ID FETCH AND CID LPAREN ID WITH ## -## Ends in an error in state: 293. +## Ends in an error in state: 291. ## ## separated_nonempty_list(COMMA,sident) -> sident . [ RPAREN ] ## separated_nonempty_list(COMMA,sident) -> sident . COMMA separated_nonempty_list(COMMA,sident) [ RPAREN ] @@ -2978,7 +2981,7 @@ Ends in an error in state: 291. Please report your example at https://github.com stmts_term: ID FETCH AND CID LPAREN ID COMMA WITH ## -## Ends in an error in state: 294. +## Ends in an error in state: 292. ## ## separated_nonempty_list(COMMA,sident) -> sident COMMA . separated_nonempty_list(COMMA,sident) [ RPAREN ] ## @@ -2988,23 +2991,11 @@ stmts_term: ID FETCH AND CID LPAREN ID COMMA WITH Ends in an error in state: 292. Please report your example at https://github.com/Zilliqa/scilla/issues. -stmts_term: RETURN WITH -## -## Ends in an error in state: 254. -## -## stmt -> RETURN . sid [ SEMICOLON EOF END BAR ] -## -## The known suffix of the stack is as follows: -## RETURN -## - - - cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN TARROW WITH ## -## Ends in an error in state: 340. +## Ends in an error in state: 338. ## -## return_type -> TARROW . typ [ THROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## return_type -> TARROW . typ [ THROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## TARROW @@ -3014,10 +3005,10 @@ cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN R cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN TARROW CID RPAREN ## -## Ends in an error in state: 341. +## Ends in an error in state: 339. ## -## return_type -> TARROW typ . [ THROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] -## typ -> typ . TARROW typ [ THROW TARROW SEND RETURN MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## return_type -> TARROW typ . [ THROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## typ -> typ . TARROW typ [ THROW TARROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## TARROW typ diff --git a/src/base/ScillaLexer.mll b/src/base/ScillaLexer.mll index 576dc0e11..57000f6f0 100644 --- a/src/base/ScillaLexer.mll +++ b/src/base/ScillaLexer.mll @@ -88,7 +88,6 @@ rule read = | "event" { EVENT } | "field" { FIELD } | "accept" { ACCEPT } - | "return" { RETURN } | "exists" { EXISTS } | "delete" { DELETE } | "Emp" { EMP } diff --git a/src/base/ScillaParser.mly b/src/base/ScillaParser.mly index d664c369d..862a9a237 100644 --- a/src/base/ScillaParser.mly +++ b/src/base/ScillaParser.mly @@ -154,7 +154,6 @@ %token SEND %token EVENT %token ACCEPT -%token RETURN %token MAP %token DELETE %token EXISTS @@ -427,7 +426,12 @@ stmt: | DELETE; l = ID; keys = nonempty_list(map_access) { MapUpdate( to_loc_id l (toLoc $startpos(l)), keys, None), toLoc $startpos } | ACCEPT { (AcceptPayment, toLoc $startpos) } -| RETURN; i = sid; { (Return (ParserIdentifier.mk_id i (toLoc $startpos(i))), toLoc $startpos) } +| kw = SPID; ASSIGN; i = sid { + if String.equal kw "_return" then + (Return (ParserIdentifier.mk_id i (toLoc $startpos(kw))), toLoc $startpos) + else + raise (SyntaxError (Printf.sprintf "Illegal assignment to %s" kw, toLoc $startpos(kw))) + } | SEND; m = sid; { (SendMsgs (ParserIdentifier.mk_id m (toLoc $startpos(m))), toLoc $startpos) } | EVENT; m = sid; { (CreateEvnt (ParserIdentifier.mk_id m (toLoc $startpos(m))), toLoc $startpos) } | THROW; mopt = option(sid); { Throw (Core.Option.map mopt ~f:(fun m -> (ParserIdentifier.mk_id m (toLoc $startpos(mopt))))), toLoc $startpos } diff --git a/src/formatter/Formatter.ml b/src/formatter/Formatter.ml index 6bd275b92..426d503b3 100644 --- a/src/formatter/Formatter.ml +++ b/src/formatter/Formatter.ml @@ -58,7 +58,6 @@ struct let delete_kwd = !^"delete" let exists_kwd = !^"exists" let accept_kwd = !^"accept" - let return_kwd = !^"return" let as_kwd = !^"as" let send_kwd = !^"send" let event_kwd = !^"event" @@ -425,7 +424,7 @@ struct | Ast.AcceptPayment -> accept_kwd | Ast.Return id -> - return_kwd ^//^ of_ann_id id + !^"_return" ^//^ assign ^//^ of_ann_id id | Ast.Iterate (arg_list, proc) -> (* forall l p *) forall_kwd ^//^ of_ann_id arg_list ^//^ of_ann_id proc diff --git a/tests/base/parser/bad/Bad.ml b/tests/base/parser/bad/Bad.ml index 2d1c72d44..ec0a9771d 100644 --- a/tests/base/parser/bad/Bad.ml +++ b/tests/base/parser/bad/Bad.ml @@ -138,6 +138,7 @@ module Tests = Scilla_test.Util.DiffBasedTests (struct "type_t-tid-arrow-with.scilla"; "address_spid_as_field.scilla"; "remote_read_namespace.scilla"; + "return-1.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 1 diff --git a/tests/base/parser/bad/gold/return-1.scilla.gold b/tests/base/parser/bad/gold/return-1.scilla.gold new file mode 100644 index 000000000..cec743db5 --- /dev/null +++ b/tests/base/parser/bad/gold/return-1.scilla.gold @@ -0,0 +1,14 @@ +{ + "errors": [ + { + "error_message": "Syntax error: Illegal assignment to _foo", + "start_location": { + "file": "base/parser/bad/return-1.scilla", + "line": 9, + "column": 3 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [] +} \ No newline at end of file diff --git a/tests/base/parser/bad/return-1.scilla b/tests/base/parser/bad/return-1.scilla new file mode 100644 index 000000000..91b4b4a12 --- /dev/null +++ b/tests/base/parser/bad/return-1.scilla @@ -0,0 +1,10 @@ +scilla_version 0 + +library ReturnBad1 + +contract ReturnBad1() + +procedure test() + (* Only [_return := x] assignments are allowed by the parser *) + _foo := _creation_block; +end diff --git a/tests/checker/bad/gold/return-bad3.scilla.gold b/tests/checker/bad/gold/return-bad3.scilla.gold index 5308765cc..53d8ca4f5 100644 --- a/tests/checker/bad/gold/return-bad3.scilla.gold +++ b/tests/checker/bad/gold/return-bad3.scilla.gold @@ -6,7 +6,7 @@ "start_location": { "file": "checker/bad/return-bad3.scilla", "line": 9, - "column": 10 + "column": 3 }, "end_location": { "file": "", "line": 0, "column": 0 } } diff --git a/tests/checker/bad/gold/return-bad6.scilla.gold b/tests/checker/bad/gold/return-bad6.scilla.gold index a60360253..1eb46fb8f 100644 --- a/tests/checker/bad/gold/return-bad6.scilla.gold +++ b/tests/checker/bad/gold/return-bad6.scilla.gold @@ -6,7 +6,7 @@ "start_location": { "file": "checker/bad/return-bad6.scilla", "line": 19, - "column": 14 + "column": 7 }, "end_location": { "file": "", "line": 0, "column": 0 } } diff --git a/tests/checker/bad/return-bad1.scilla b/tests/checker/bad/return-bad1.scilla index d6ccdbf36..1b9dd8633 100644 --- a/tests/checker/bad/return-bad1.scilla +++ b/tests/checker/bad/return-bad1.scilla @@ -9,5 +9,5 @@ procedure no_return() -> BNum end procedure no_return_fixed() -> BNum ret = _creation_block; - return ret (* OK *) + _return := ret (* OK *) end diff --git a/tests/checker/bad/return-bad2.scilla b/tests/checker/bad/return-bad2.scilla index 9035b846c..a5783bd7c 100644 --- a/tests/checker/bad/return-bad2.scilla +++ b/tests/checker/bad/return-bad2.scilla @@ -8,7 +8,7 @@ procedure match_no_ret(a: Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block (* Error: no return *) @@ -18,9 +18,9 @@ procedure match_no_ret_fixed(a: Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block; - return ret (* OK *) + _return := ret (* OK *) end end diff --git a/tests/checker/bad/return-bad3.scilla b/tests/checker/bad/return-bad3.scilla index 1302df16f..1548ed06c 100644 --- a/tests/checker/bad/return-bad3.scilla +++ b/tests/checker/bad/return-bad3.scilla @@ -6,10 +6,10 @@ contract ReturnBad3() procedure dead_code() -> BNum ret = _creation_block; - return ret; + _return := ret; dead = _creation_block (* Error *) end procedure dead_code_fixed() -> BNum ret = _creation_block; - return ret + _return := ret end diff --git a/tests/checker/bad/return-bad4.scilla b/tests/checker/bad/return-bad4.scilla index 20e40dc64..102baef87 100644 --- a/tests/checker/bad/return-bad4.scilla +++ b/tests/checker/bad/return-bad4.scilla @@ -7,10 +7,10 @@ procedure dead_code_match (a : Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block; - return ret + _return := ret end; dead = _creation_block (* Error *) end @@ -18,10 +18,10 @@ procedure dead_code_match_fixed (a : Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block; - return ret + _return := ret end end diff --git a/tests/checker/bad/return-bad5.scilla b/tests/checker/bad/return-bad5.scilla index 9108de3d0..6f976bcdc 100644 --- a/tests/checker/bad/return-bad5.scilla +++ b/tests/checker/bad/return-bad5.scilla @@ -6,12 +6,12 @@ procedure nested_match_no_ret(a: Bool, b: Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => match b with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block (* Error: no return *) @@ -22,15 +22,15 @@ procedure nested_match_no_ret_fixed(a: Bool, b: Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => match b with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block; - return ret (* OK *) + _return := ret (* OK *) end end end diff --git a/tests/checker/bad/return-bad6.scilla b/tests/checker/bad/return-bad6.scilla index 3cad4e3c7..d9a7a82f1 100644 --- a/tests/checker/bad/return-bad6.scilla +++ b/tests/checker/bad/return-bad6.scilla @@ -8,15 +8,15 @@ procedure dead_code_in_match(a: Bool, b: Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => match b with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block; - return ret; + _return := ret; dead = _creation_block (* Error *) end end @@ -25,15 +25,15 @@ procedure dead_code_in_match_fixed(a: Bool, b: Bool) -> BNum match a with | True => ret = _creation_block; - return ret + _return := ret | False => match b with | True => ret = _creation_block; - return ret + _return := ret | False => ret = _creation_block; - return ret + _return := ret (* Fixed *) end end diff --git a/tests/contracts/dead_code_test8.scilla b/tests/contracts/dead_code_test8.scilla index 720211527..772f7134e 100644 --- a/tests/contracts/dead_code_test8.scilla +++ b/tests/contracts/dead_code_test8.scilla @@ -6,11 +6,11 @@ contract Dead8 () procedure pr1() -> Bool res = True; - return res + _return := res end procedure pr2(a: Bool) -> Bool - return a + _return := a end transition test_dead_variable1() diff --git a/tests/contracts/procedure-return-1.scilla b/tests/contracts/return-1.scilla similarity index 93% rename from tests/contracts/procedure-return-1.scilla rename to tests/contracts/return-1.scilla index 32e778037..3bf3ad1b6 100644 --- a/tests/contracts/procedure-return-1.scilla +++ b/tests/contracts/return-1.scilla @@ -10,7 +10,7 @@ field f : Int32 = Int32 0 procedure return_one() -> Int32 a = one; - return a + _return := a end procedure forbid_negative_f() @@ -28,13 +28,13 @@ end procedure id(x: Int32) -> Int32 forbid_negative_f; - return x + _return := x end procedure add(lhs: Int32, rhs: Int32) -> Int32 lhs_ = id lhs; s = builtin add lhs_ rhs; - return s + _return := s end transition f_add_one() diff --git a/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla b/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla index 97f62c166..0449590ef 100644 --- a/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla +++ b/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla @@ -10,16 +10,16 @@ field f : Uint32 = Uint32 0 procedure return_one() -> Uint32 a = one; - return a + _return := a end procedure id(x: Uint32) -> Uint32 - return x + _return := x end procedure add(lhs: Uint32, rhs: Uint32) -> Uint32 s = builtin add lhs rhs; - return s + _return := s end transition f_add_one() diff --git a/tests/formatter/look_and_feel/return.t/return.scilla b/tests/formatter/look_and_feel/return.t/return.scilla index 7ab7a8bff..efeb56935 100644 --- a/tests/formatter/look_and_feel/return.t/return.scilla +++ b/tests/formatter/look_and_feel/return.t/return.scilla @@ -6,16 +6,16 @@ contract Return() procedure no_return() a = _creation_block; - return a + _return := a end procedure incorrect_return_type() -> (String) a = _creation_block; - return a + _return := a end procedure return_1() -> BNum a = _creation_block; - return a + _return := a end diff --git a/tests/formatter/look_and_feel/return.t/run.t b/tests/formatter/look_and_feel/return.t/run.t index 2baf16b85..ad2ddbb4d 100644 --- a/tests/formatter/look_and_feel/return.t/run.t +++ b/tests/formatter/look_and_feel/return.t/run.t @@ -9,15 +9,15 @@ procedure no_return () a = _creation_block; - return a + _return := a end procedure incorrect_return_type () -> String a = _creation_block; - return a + _return := a end procedure return_1 () -> BNum a = _creation_block; - return a + _return := a end diff --git a/tests/runner/Testcontracts.ml b/tests/runner/Testcontracts.ml index 61126132f..fd1310505 100644 --- a/tests/runner/Testcontracts.ml +++ b/tests/runner/Testcontracts.ml @@ -497,8 +497,8 @@ let contract_tests env = *) "ark-store-hashes-in-mutable-maps" >::: build_contract_tests env "ark" succ_code 1 1 []; - "procedure-return-1" - >::: build_contract_tests env "procedure-return-1" succ_code 1 1 + "return-1" + >::: build_contract_tests env "return-1" succ_code 1 1 []; ]; "these_tests_must_FAIL" diff --git a/tests/runner/procedure-return-1/blockchain_0.json b/tests/runner/return-1/blockchain_0.json similarity index 100% rename from tests/runner/procedure-return-1/blockchain_0.json rename to tests/runner/return-1/blockchain_0.json diff --git a/tests/runner/procedure-return-1/blockchain_1.json b/tests/runner/return-1/blockchain_1.json similarity index 100% rename from tests/runner/procedure-return-1/blockchain_1.json rename to tests/runner/return-1/blockchain_1.json diff --git a/tests/runner/procedure-return-1/init.json b/tests/runner/return-1/init.json similarity index 100% rename from tests/runner/procedure-return-1/init.json rename to tests/runner/return-1/init.json diff --git a/tests/runner/procedure-return-1/message_0.json b/tests/runner/return-1/message_0.json similarity index 100% rename from tests/runner/procedure-return-1/message_0.json rename to tests/runner/return-1/message_0.json diff --git a/tests/runner/procedure-return-1/message_1.json b/tests/runner/return-1/message_1.json similarity index 100% rename from tests/runner/procedure-return-1/message_1.json rename to tests/runner/return-1/message_1.json diff --git a/tests/runner/procedure-return-1/output_0.json b/tests/runner/return-1/output_0.json similarity index 100% rename from tests/runner/procedure-return-1/output_0.json rename to tests/runner/return-1/output_0.json diff --git a/tests/runner/procedure-return-1/output_1.json b/tests/runner/return-1/output_1.json similarity index 100% rename from tests/runner/procedure-return-1/output_1.json rename to tests/runner/return-1/output_1.json diff --git a/tests/runner/procedure-return-1/state_0.json b/tests/runner/return-1/state_0.json similarity index 100% rename from tests/runner/procedure-return-1/state_0.json rename to tests/runner/return-1/state_0.json diff --git a/tests/runner/procedure-return-1/state_1.json b/tests/runner/return-1/state_1.json similarity index 100% rename from tests/runner/procedure-return-1/state_1.json rename to tests/runner/return-1/state_1.json From 2f282fe34aeeb34a8511c5f50e70be048310aa4b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 8 Dec 2022 19:38:17 +0700 Subject: [PATCH 37/41] feat(tests): More tests for contract addresses --- tests/checker/bad/Bad.ml | 1 + .../checker/bad/gold/return-bad7.scilla.gold | 15 ++++ tests/checker/bad/return-bad7.scilla | 11 +++ tests/checker/good/Good.ml | 1 + tests/checker/good/gold/return-1.scilla.gold | 85 +++++++++++++++++++ tests/checker/good/return-1.scilla | 11 +++ 6 files changed, 124 insertions(+) create mode 100644 tests/checker/bad/gold/return-bad7.scilla.gold create mode 100644 tests/checker/bad/return-bad7.scilla create mode 100644 tests/checker/good/gold/return-1.scilla.gold create mode 100644 tests/checker/good/return-1.scilla diff --git a/tests/checker/bad/Bad.ml b/tests/checker/bad/Bad.ml index a8936c866..1477519ac 100644 --- a/tests/checker/bad/Bad.ml +++ b/tests/checker/bad/Bad.ml @@ -145,6 +145,7 @@ module LibTests = Scilla_test.Util.DiffBasedTests (struct "return-bad4.scilla"; "return-bad5.scilla"; "return-bad6.scilla"; + "return-bad7.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 1 diff --git a/tests/checker/bad/gold/return-bad7.scilla.gold b/tests/checker/bad/gold/return-bad7.scilla.gold new file mode 100644 index 000000000..43f78ebcf --- /dev/null +++ b/tests/checker/bad/gold/return-bad7.scilla.gold @@ -0,0 +1,15 @@ +{ + "gas_remaining": "8000", + "errors": [ + { + "error_message": "Type unassignable: ByStr20 with contract field x : Uint128, field y : Bool end expected, but ByStr20 with contract field x : Uint128 end provided", + "start_location": { + "file": "checker/bad/return-bad7.scilla", + "line": 10, + "column": 3 + }, + "end_location": { "file": "", "line": 0, "column": 0 } + } + ], + "warnings": [] +} \ No newline at end of file diff --git a/tests/checker/bad/return-bad7.scilla b/tests/checker/bad/return-bad7.scilla new file mode 100644 index 000000000..65097100e --- /dev/null +++ b/tests/checker/bad/return-bad7.scilla @@ -0,0 +1,11 @@ +scilla_version 0 + +library ReturnBad7 + +contract ReturnBad7 () + +procedure test + (x : ByStr20 with contract field x : Uint128 end) + -> ByStr20 with contract field x : Uint128, field y : Bool end + _return := x +end diff --git a/tests/checker/good/Good.ml b/tests/checker/good/Good.ml index 358ce3c80..0954a7112 100644 --- a/tests/checker/good/Good.ml +++ b/tests/checker/good/Good.ml @@ -183,6 +183,7 @@ module CheckerTests = Scilla_test.Util.DiffBasedTests (struct "blowup_1.scilla"; "blowup_2.scilla"; "builtin_type_args.scilla"; + "return-1.scilla"; ] let exit_code : UnixLabels.process_status = WEXITED 0 diff --git a/tests/checker/good/gold/return-1.scilla.gold b/tests/checker/good/gold/return-1.scilla.gold new file mode 100644 index 000000000..5bfe6c88b --- /dev/null +++ b/tests/checker/good/gold/return-1.scilla.gold @@ -0,0 +1,85 @@ +{ + "cashflow_tags": { "State variables": [], "ADT constructors": [] }, + "contract_info": { + "scilla_major_version": "0", + "vname": "ReturnGood1", + "params": [], + "fields": [], + "transitions": [], + "procedures": [ + { + "vname": "test", + "params": [ + { + "vname": "x", + "type": "ByStr20 with contract field x : Uint128, field y : Bool end" + } + ] + } + ], + "events": [], + "ADTs": [ + { + "tname": "Option", + "tparams": [ "'A" ], + "tmap": [ + { "cname": "Some", "argtypes": [ "'A" ] }, + { "cname": "None", "argtypes": [] } + ] + }, + { + "tname": "Bool", + "tparams": [], + "tmap": [ + { "cname": "True", "argtypes": [] }, + { "cname": "False", "argtypes": [] } + ] + }, + { + "tname": "Nat", + "tparams": [], + "tmap": [ + { "cname": "Zero", "argtypes": [] }, + { "cname": "Succ", "argtypes": [ "Nat" ] } + ] + }, + { + "tname": "List", + "tparams": [ "'A" ], + "tmap": [ + { "cname": "Cons", "argtypes": [ "'A", "List ('A)" ] }, + { "cname": "Nil", "argtypes": [] } + ] + }, + { + "tname": "Pair", + "tparams": [ "'A", "'B" ], + "tmap": [ { "cname": "Pair", "argtypes": [ "'A", "'B" ] } ] + } + ] + }, + "warnings": [ + { + "warning_message": "Unused procedure: test", + "start_location": { + "file": "checker/good/return-1.scilla", + "line": 7, + "column": 11 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 3 + }, + { + "warning_message": "No transition in contract ReturnGood1 contains an accept statement\n", + "start_location": { + "file": "checker/good/return-1.scilla", + "line": 5, + "column": 10 + }, + "end_location": { "file": "", "line": 0, "column": 0 }, + "warning_id": 1 + } + ], + "gas_remaining": "7999" +} + diff --git a/tests/checker/good/return-1.scilla b/tests/checker/good/return-1.scilla new file mode 100644 index 000000000..85fd77857 --- /dev/null +++ b/tests/checker/good/return-1.scilla @@ -0,0 +1,11 @@ +scilla_version 0 + +library ReturnGood1 + +contract ReturnGood1 () + +procedure test + (x : ByStr20 with contract field x : Uint128, field y : Bool end) + -> ByStr20 with contract field x : Uint128 end + _return := x +end From f8265fa57f1c0d3207a104d7202bf40ff3d4e4da Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 9 Dec 2022 13:52:13 +0700 Subject: [PATCH 38/41] feat(syntax): Use `procedure x() : type` concrete syntax --- src/base/ParserFaults.messages | 281 ++++++++++-------- src/base/ScillaParser.mly | 2 +- src/formatter/Formatter.ml | 2 +- tests/checker/bad/return-bad1.scilla | 4 +- tests/checker/bad/return-bad2.scilla | 4 +- tests/checker/bad/return-bad3.scilla | 4 +- tests/checker/bad/return-bad4.scilla | 4 +- tests/checker/bad/return-bad5.scilla | 4 +- tests/checker/bad/return-bad6.scilla | 4 +- tests/checker/bad/return-bad7.scilla | 2 +- tests/checker/good/return-1.scilla | 2 +- tests/contracts/dead_code_test8.scilla | 4 +- tests/contracts/return-1.scilla | 6 +- .../procedure-return-1.scilla | 6 +- .../look_and_feel/return.t/return.scilla | 4 +- 15 files changed, 180 insertions(+), 153 deletions(-) diff --git a/src/base/ParserFaults.messages b/src/base/ParserFaults.messages index 477e96910..54aa38de0 100644 --- a/src/base/ParserFaults.messages +++ b/src/base/ParserFaults.messages @@ -13,6 +13,9 @@ #@ WARNING: #@ The following comment has been copied from "src/base/ParserFaults.messages". #@ It may need to be proofread, updated, moved, or removed. +#@ WARNING: +#@ The following comment has been copied from "src/base/ParserFaults.messages". +#@ It may need to be proofread, updated, moved, or removed. # This file is part of scilla. # # Copyright (c) 2018 - present Zilliqa Research Pvt. Ltd. @@ -43,7 +46,7 @@ type_term: CID LPAREN TID WITH ## ## Ends in an error in state: 74. ## -## targ -> LPAREN typ . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> LPAREN typ . RPAREN [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## typ -> typ . TARROW typ [ TARROW RPAREN ] ## ## The known suffix of the stack is as follows: @@ -57,7 +60,7 @@ type_term: CID LPAREN WITH ## ## Ends in an error in state: 73. ## -## targ -> LPAREN . typ RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> LPAREN . typ RPAREN [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -70,7 +73,7 @@ type_term: CID MAP WITH ## ## Ends in an error in state: 20. ## -## targ -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -83,7 +86,7 @@ type_term: CID PERIOD WITH ## ## Ends in an error in state: 57. ## -## scid -> CID PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID PERIOD . CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID PERIOD @@ -96,7 +99,7 @@ type_term: CID TID WITH ## ## Ends in an error in state: 77. ## -## list(targ) -> targ . list(targ) [ THROW TARROW SEND RPAREN RBRACE MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## list(targ) -> targ . list(targ) [ THROW TARROW SPID SEND RPAREN RBRACE MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## targ @@ -109,8 +112,8 @@ type_term: FORALL TID PERIOD TID WITH ## ## Ends in an error in state: 69. ## -## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] -## typ -> FORALL TID PERIOD typ . [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ . TARROW typ [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL TID PERIOD typ . [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID PERIOD typ @@ -123,7 +126,7 @@ type_term: FORALL TID PERIOD WITH ## ## Ends in an error in state: 68. ## -## typ -> FORALL TID PERIOD . typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL TID PERIOD . typ [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID PERIOD @@ -136,7 +139,7 @@ type_term: FORALL TID WITH ## ## Ends in an error in state: 67. ## -## typ -> FORALL TID . PERIOD typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL TID . PERIOD typ [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL TID @@ -149,7 +152,7 @@ type_term: FORALL WITH ## ## Ends in an error in state: 66. ## -## typ -> FORALL . TID PERIOD typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> FORALL . TID PERIOD typ [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## FORALL @@ -163,7 +166,7 @@ type_term: LPAREN TID WITH ## Ends in an error in state: 82. ## ## typ -> typ . TARROW typ [ TARROW RPAREN ] -## typ -> LPAREN typ . RPAREN [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> LPAREN typ . RPAREN [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN typ @@ -176,7 +179,7 @@ type_term: LPAREN WITH ## ## Ends in an error in state: 65. ## -## typ -> LPAREN . typ RPAREN [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> LPAREN . typ RPAREN [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -204,7 +207,7 @@ type_term: MAP CID LPAREN MAP WITH ## ## Ends in an error in state: 39. ## -## t_map_value -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> MAP . t_map_key t_map_value [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -217,7 +220,7 @@ type_term: MAP CID LPAREN WITH ## ## Ends in an error in state: 41. ## -## t_map_value -> LPAREN . t_map_value_allow_targs RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> LPAREN . t_map_value_allow_targs RPAREN [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -230,13 +233,13 @@ type_term: MAP CID UNDERSCORE ## ## Ends in an error in state: 25. ## -## address_typ -> CID . WITH END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID . WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## scid -> CID . [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## scid -> CID . PERIOD CID [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH LIBRARY END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH SPID END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID . WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID . [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> CID . PERIOD CID [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID @@ -263,7 +266,7 @@ type_term: MAP WITH ## ## Ends in an error in state: 37. ## -## typ -> MAP . t_map_key t_map_value [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> MAP . t_map_key t_map_value [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP @@ -276,8 +279,8 @@ type_term: TID TARROW TID WITH ## ## Ends in an error in state: 71. ## -## typ -> typ . TARROW typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] -## typ -> typ TARROW typ . [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ . TARROW typ [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ TARROW typ . [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## typ TARROW typ @@ -290,7 +293,7 @@ type_term: TID TARROW WITH ## ## Ends in an error in state: 70. ## -## typ -> typ TARROW . typ [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> typ TARROW . typ [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## typ TARROW @@ -303,11 +306,11 @@ type_term: CID WITH EOF ## ## Ends in an error in state: 26. ## -## address_typ -> CID WITH . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . LIBRARY END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . SPID END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH . CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . LIBRARY END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . SPID END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH . CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH @@ -318,7 +321,7 @@ Invalid or incomplete type. type_term: TID WITH ## -## Ends in an error in state: 373. +## Ends in an error in state: 376. ## ## typ -> typ . TARROW typ [ TARROW EOF ] ## type_term -> typ . EOF [ # ] @@ -332,7 +335,7 @@ This is an invalid type term, the ADT constructor arguments are likely incorrect type_term: WITH ## -## Ends in an error in state: 371. +## Ends in an error in state: 374. ## ## type_term' -> . type_term [ # ] ## @@ -345,7 +348,7 @@ This is an invalid type term. stmts_term: ACCEPT WITH ## -## Ends in an error in state: 319. +## Ends in an error in state: 322. ## ## separated_nonempty_list(SEMICOLON,stmt) -> stmt . [ EOF END BAR ] ## separated_nonempty_list(SEMICOLON,stmt) -> stmt . SEMICOLON separated_nonempty_list(SEMICOLON,stmt) [ EOF END BAR ] @@ -360,7 +363,7 @@ This is likely an improperly terminated statement (lacking the semicolon). stmts_term: CID WITH ## -## Ends in an error in state: 323. +## Ends in an error in state: 326. ## ## stmt -> component_id . list(sident) [ SEMICOLON EOF END BAR ] ## @@ -373,7 +376,7 @@ This is an invalid statements term. stmts_term: DELETE ID WITH ## -## Ends in an error in state: 316. +## Ends in an error in state: 319. ## ## stmt -> DELETE ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -386,7 +389,7 @@ This is an invalid delete statement, it lacks the keys to delete. stmts_term: DELETE WITH ## -## Ends in an error in state: 315. +## Ends in an error in state: 318. ## ## stmt -> DELETE . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -399,7 +402,7 @@ This is an invalid delete statement, it lacks a map to delete from. stmts_term: EVENT WITH ## -## Ends in an error in state: 313. +## Ends in an error in state: 316. ## ## stmt -> EVENT . sid [ SEMICOLON EOF END BAR ] ## @@ -412,7 +415,7 @@ This is an invalid event statement, it lacks a separated identifier for the even stmts_term: ID ASSIGN WITH ## -## Ends in an error in state: 305. +## Ends in an error in state: 308. ## ## stmt -> ID ASSIGN . sid [ SEMICOLON EOF END BAR ] ## @@ -425,7 +428,7 @@ This is an invalid assign statement, it lacks a separated identifier. stmts_term: ID FETCH AND WITH ## -## Ends in an error in state: 272. +## Ends in an error in state: 275. ## ## remote_fetch_stmt -> ID FETCH AND . ID PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND . SPID PERIOD SPID [ SEMICOLON EOF END BAR ] @@ -444,7 +447,7 @@ This is an invalid bind and statement. The parser expects a capital identifier a stmts_term: ID FETCH EXISTS ID WITH ## -## Ends in an error in state: 270. +## Ends in an error in state: 273. ## ## stmt -> ID FETCH EXISTS ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -457,7 +460,7 @@ This is an invalid existence bind statement. It lacks a non-empty list of access stmts_term: ID FETCH EXISTS WITH ## -## Ends in an error in state: 269. +## Ends in an error in state: 272. ## ## stmt -> ID FETCH EXISTS . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -470,7 +473,7 @@ This is an invalid existence bind statement. It lacks a map to check existence o stmts_term: ID FETCH ID WITH ## -## Ends in an error in state: 265. +## Ends in an error in state: 268. ## ## sid -> ID . [ SEMICOLON EOF END BAR ] ## stmt -> ID FETCH ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] @@ -484,7 +487,7 @@ This is an invalid bind statement, it is lacking a non empty list of map accesse stmts_term: ID FETCH WITH ## -## Ends in an error in state: 264. +## Ends in an error in state: 267. ## ## remote_fetch_stmt -> ID FETCH . AND ID PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH . AND SPID PERIOD SPID [ SEMICOLON EOF END BAR ] @@ -506,7 +509,7 @@ This is an invalid bind statement, the bind can be followed by '&', 'exists' or stmts_term: ID EQ WITH ## -## Ends in an error in state: 303. +## Ends in an error in state: 306. ## ## stmt -> ID EQ . exp [ SEMICOLON EOF END BAR ] ## @@ -519,7 +522,7 @@ This is an invalid equal statement, it is lacking a valid expression on the righ stmts_term: ID LSQB SPID RSQB ASSIGN WITH ## -## Ends in an error in state: 308. +## Ends in an error in state: 311. ## ## stmt -> ID nonempty_list(map_access) ASSIGN . sid [ SEMICOLON EOF END BAR ] ## @@ -532,7 +535,7 @@ The map key must be assigned to some separated identifier. stmts_term: ID LSQB SPID RSQB SEMICOLON ## -## Ends in an error in state: 307. +## Ends in an error in state: 310. ## ## stmt -> ID nonempty_list(map_access) . ASSIGN sid [ SEMICOLON EOF END BAR ] ## @@ -543,7 +546,7 @@ stmts_term: ID LSQB SPID RSQB SEMICOLON ## This implies that, although the LR(1) items shown above provide an ## accurate view of the past (what has been recognized so far), they ## may provide an INCOMPLETE view of the future (what was expected next). -## In state 267, spurious reduction of production nonempty_list(map_access) -> map_access +## In state 270, spurious reduction of production nonempty_list(map_access) -> map_access ## # see tests/parser/bad/stmts_t-id-lsqb-spid-rsqb-semicolon.scilla @@ -551,7 +554,7 @@ This is likely an invalid map assign statement, it lacks the assign. stmts_term: ID LSQB SPID RSQB WITH ## -## Ends in an error in state: 267. +## Ends in an error in state: 270. ## ## nonempty_list(map_access) -> map_access . [ SEMICOLON EOF END BAR ASSIGN ] ## nonempty_list(map_access) -> map_access . nonempty_list(map_access) [ SEMICOLON EOF END BAR ASSIGN ] @@ -565,7 +568,7 @@ This is an invalid statements term. A possible continuation may be assigning a m stmts_term: ID LSQB SPID WITH ## -## Ends in an error in state: 262. +## Ends in an error in state: 265. ## ## map_access -> LSQB sident . RSQB [ SEMICOLON LSQB EOF END BAR ASSIGN ] ## @@ -578,7 +581,7 @@ This is an invalid statements term. A possible continuation may be accessing a k stmts_term: ID LSQB WITH ## -## Ends in an error in state: 261. +## Ends in an error in state: 264. ## ## map_access -> LSQB . sident RSQB [ SEMICOLON LSQB EOF END BAR ASSIGN ] ## @@ -604,7 +607,7 @@ This is an invalid statements term, likely a bad procedure call with faulty argu stmts_term: ID WITH ## -## Ends in an error in state: 260. +## Ends in an error in state: 263. ## ## component_id -> ID . [ SPID SEMICOLON ID EOF END CID BAR ] ## remote_fetch_stmt -> ID . FETCH AND ID PERIOD sident [ SEMICOLON EOF END BAR ] @@ -630,7 +633,7 @@ This is an invalid statements term. Scilla expects to do something with the iden stmts_term: MATCH SPID UNDERSCORE ## -## Ends in an error in state: 255. +## Ends in an error in state: 258. ## ## stmt -> MATCH sid . WITH list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -643,7 +646,7 @@ This is an invalid match statement, 'with' is expected after what is specified t stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW ACCEPT EOF ## -## Ends in an error in state: 327. +## Ends in an error in state: 330. ## ## list(stmt_pm_clause) -> stmt_pm_clause . list(stmt_pm_clause) [ END ] ## @@ -654,9 +657,9 @@ stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW ACCEPT EOF ## This implies that, although the LR(1) items shown above provide an ## accurate view of the past (what has been recognized so far), they ## may provide an INCOMPLETE view of the future (what was expected next). -## In state 319, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 325, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 326, spurious reduction of production stmt_pm_clause -> BAR pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 322, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 328, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 329, spurious reduction of production stmt_pm_clause -> BAR pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) ## # see tests/parser/bad/stmts_t-match-spid-with-bar-underscore-arrow-accept-eof.scilla @@ -664,7 +667,7 @@ When the match statement is finished, the parser expects 'end'. stmts_term: MATCH SPID WITH BAR UNDERSCORE ARROW WITH ## -## Ends in an error in state: 259. +## Ends in an error in state: 262. ## ## stmt_pm_clause -> BAR pattern ARROW . loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -677,7 +680,7 @@ This is an invalid statements term. In the match expression, after an arrow the stmts_term: MATCH SPID WITH BAR UNDERSCORE WITH ## -## Ends in an error in state: 258. +## Ends in an error in state: 261. ## ## stmt_pm_clause -> BAR pattern . ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -690,7 +693,7 @@ This is an invalid statements term. In the match expression, after a pattern is stmts_term: MATCH SPID WITH BAR WITH ## -## Ends in an error in state: 257. +## Ends in an error in state: 260. ## ## stmt_pm_clause -> BAR . pattern ARROW loption(separated_nonempty_list(SEMICOLON,stmt)) [ END BAR ] ## @@ -703,7 +706,7 @@ In the match statement there is a malformed pattern. stmts_term: MATCH SPID WITH WITH ## -## Ends in an error in state: 256. +## Ends in an error in state: 259. ## ## stmt -> MATCH sid WITH . list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -716,7 +719,7 @@ There is a malformed pattern matching clause, the bar is likely missing. stmts_term: MATCH WITH ## -## Ends in an error in state: 254. +## Ends in an error in state: 257. ## ## stmt -> MATCH . sid WITH list(stmt_pm_clause) END [ SEMICOLON EOF END BAR ] ## @@ -755,7 +758,7 @@ This send statement is either unfinished or not properly terminated. stmts_term: SEND WITH ## -## Ends in an error in state: 252. +## Ends in an error in state: 255. ## ## stmt -> SEND . sid [ SEMICOLON EOF END BAR ] ## @@ -768,7 +771,7 @@ It is expected to send to a separated identifier. stmts_term: THROW END ## -## Ends in an error in state: 369. +## Ends in an error in state: 372. ## ## stmts_term -> stmts . EOF [ # ] ## @@ -781,9 +784,9 @@ stmts_term: THROW END ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 249, spurious reduction of production option(sid) -> ## In state 251, spurious reduction of production stmt -> THROW option(sid) -## In state 319, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 325, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 333, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 322, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 328, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 336, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) ## # special case, only via stmts_term entry point should never happen # throw itself is a valid statement term and a procedure or transition @@ -793,7 +796,7 @@ This is an invalid statements term, bad throw. stmts_term: THROW SEMICOLON WITH ## -## Ends in an error in state: 320. +## Ends in an error in state: 323. ## ## separated_nonempty_list(SEMICOLON,stmt) -> stmt SEMICOLON . separated_nonempty_list(SEMICOLON,stmt) [ EOF END BAR ] ## @@ -821,7 +824,7 @@ This throw does not throw a valid exception or is not properly terminated. stmts_term: WITH ## -## Ends in an error in state: 367. +## Ends in an error in state: 370. ## ## stmts_term' -> . stmts_term [ # ] ## @@ -874,7 +877,7 @@ To import another library mention the new library name directly after the previo lmodule: SCILLA_VERSION NUMLIT IMPORT CONTRACT ## -## Ends in an error in state: 363. +## Ends in an error in state: 366. ## ## lmodule -> SCILLA_VERSION NUMLIT imports . library EOF [ # ] ## @@ -907,7 +910,7 @@ If import is mentioned there must be one or more imported libraries with capital lmodule: SCILLA_VERSION NUMLIT LIBRARY CID CONTRACT ## -## Ends in an error in state: 364. +## Ends in an error in state: 367. ## ## lmodule -> SCILLA_VERSION NUMLIT imports library . EOF [ # ] ## @@ -1126,7 +1129,7 @@ This is an invalid library module because it lacks a capital identifier for a na lmodule: SCILLA_VERSION NUMLIT WITH ## -## Ends in an error in state: 362. +## Ends in an error in state: 365. ## ## lmodule -> SCILLA_VERSION NUMLIT . imports library EOF [ # ] ## @@ -1139,7 +1142,7 @@ This is an invalid library module, Scilla version must be followed by 'library' lmodule: WITH ## -## Ends in an error in state: 360. +## Ends in an error in state: 363. ## ## lmodule' -> . lmodule [ # ] ## @@ -1749,7 +1752,7 @@ This is an invalid expression. If it is an application of a function, it is nece exp_term: STRING WITH ## -## Ends in an error in state: 358. +## Ends in an error in state: 361. ## ## exp_term -> exp . EOF [ # ] ## @@ -1801,7 +1804,7 @@ Type functions expect a type id (e.g. 'A). exp_term: WITH ## -## Ends in an error in state: 356. +## Ends in an error in state: 359. ## ## exp_term' -> . exp_term [ # ] ## @@ -1842,7 +1845,7 @@ For a mutable field declaration, the parser expects a valid lower case beginning cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE ID LPAREN RPAREN WITH ## -## Ends in an error in state: 337. +## Ends in an error in state: 340. ## ## procedure -> PROCEDURE component_id component_params . option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## @@ -1855,7 +1858,7 @@ In the transition body the parser expects a list of semi-colon separated stateme cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE ID WITH ## -## Ends in an error in state: 336. +## Ends in an error in state: 339. ## ## procedure -> PROCEDURE component_id . component_params option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## @@ -1869,7 +1872,7 @@ be a left parenthesis. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE WITH ## -## Ends in an error in state: 335. +## Ends in an error in state: 338. ## ## procedure -> PROCEDURE . component_id component_params option(return_type) component_body [ TRANSITION PROCEDURE EOF ] ## @@ -1882,7 +1885,7 @@ A procedure requires a valid name. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN RPAREN END WITH ## -## Ends in an error in state: 346. +## Ends in an error in state: 349. ## ## list(component) -> component . list(component) [ EOF ] ## @@ -1895,7 +1898,7 @@ Following a transition definition, the parser expects a transition or a procedur cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN RPAREN THROW BAR ## -## Ends in an error in state: 331. +## Ends in an error in state: 334. ## ## component_body -> stmts . END [ TRANSITION PROCEDURE EOF ] ## @@ -1908,9 +1911,9 @@ cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN R ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 249, spurious reduction of production option(sid) -> ## In state 251, spurious reduction of production stmt -> THROW option(sid) -## In state 319, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt -## In state 325, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) -## In state 333, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) +## In state 322, spurious reduction of production separated_nonempty_list(SEMICOLON,stmt) -> stmt +## In state 328, spurious reduction of production loption(separated_nonempty_list(SEMICOLON,stmt)) -> separated_nonempty_list(SEMICOLON,stmt) +## In state 336, spurious reduction of production stmts -> loption(separated_nonempty_list(SEMICOLON,stmt)) ## # see tests/parser/cmodule-transition-id-lparen-rparen-throw-bar.scilla @@ -1933,7 +1936,7 @@ cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN TRANSITION ID LPAREN W ## ## Ends in an error in state: 245. ## -## component_params -> LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN [ THROW TARROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## component_params -> LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN [ THROW SPID SEND MATCH ID FORALL EVENT END DELETE COLON CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN @@ -2041,7 +2044,7 @@ cmodule: SCILLA_VERSION NUMLIT LIBRARY CID EOF ## may provide an INCOMPLETE view of the future (what was expected next). ## In state 12, spurious reduction of production list(libentry) -> ## In state 223, spurious reduction of production library -> LIBRARY CID list(libentry) -## In state 354, spurious reduction of production option(library) -> library +## In state 357, spurious reduction of production option(library) -> library ## # see tests/parser/bad/cmodule-version-number-library-name @@ -2129,7 +2132,7 @@ type_term: CID MAP CID TYPE ## ## Ends in an error in state: 107. ## -## targ -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## targ -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2148,7 +2151,7 @@ type_term: CID TYPE ## ## Ends in an error in state: 72. ## -## typ -> scid . list(targ) [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> scid . list(targ) [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## scid @@ -2232,7 +2235,7 @@ type_term: CID WITH CONTRACT LPAREN RPAREN WITH ## ## Ends in an error in state: 92. ## -## address_typ -> CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN @@ -2244,7 +2247,7 @@ type_term: CID WITH CONTRACT LPAREN WITH ## ## Ends in an error in state: 33. ## -## address_typ -> CID WITH CONTRACT LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT LPAREN . loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT LPAREN @@ -2256,8 +2259,8 @@ type_term: CID WITH CONTRACT WITH ## ## Ends in an error in state: 32. ## -## address_typ -> CID WITH CONTRACT . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] -## address_typ -> CID WITH CONTRACT . LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT . loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH CONTRACT . LPAREN loption(separated_nonempty_list(COMMA,param_pair)) RPAREN loption(separated_nonempty_list(COMMA,address_type_field)) END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH CONTRACT @@ -2269,7 +2272,7 @@ type_term: HEXLIT WITH ## ## Ends in an error in state: 22. ## -## scid -> HEXLIT . PERIOD CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## scid -> HEXLIT . PERIOD CID [ UNDERSCORE TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## HEXLIT @@ -2281,7 +2284,7 @@ type_term: MAP CID MAP CID TYPE ## ## Ends in an error in state: 40. ## -## t_map_value -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> MAP t_map_key . t_map_value [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2300,7 +2303,7 @@ type_term: MAP CID TYPE ## ## Ends in an error in state: 38. ## -## typ -> MAP t_map_key . t_map_value [ THROW TARROW SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] +## typ -> MAP t_map_key . t_map_value [ THROW TARROW SPID SEND RPAREN MATCH ID FORALL EVENT EQ EOF END DELETE COMMA CID ACCEPT ] ## ## The known suffix of the stack is as follows: ## MAP t_map_key @@ -2347,7 +2350,7 @@ Ends in an error in state: 99. stmts_term: FORALL SPID WITH ## -## Ends in an error in state: 311. +## Ends in an error in state: 314. ## ## stmt -> FORALL sident . component_id [ SEMICOLON EOF END BAR ] ## @@ -2359,7 +2362,7 @@ Ends in an error in state: 297. stmts_term: FORALL WITH ## -## Ends in an error in state: 310. +## Ends in an error in state: 313. ## ## stmt -> FORALL . sident component_id [ SEMICOLON EOF END BAR ] ## @@ -2371,7 +2374,7 @@ Ends in an error in state: 296. stmts_term: ID FETCH AND CID PERIOD ID WITH ## -## Ends in an error in state: 298. +## Ends in an error in state: 301. ## ## remote_fetch_stmt -> ID FETCH AND sident . AS address_typ [ SEMICOLON EOF END BAR ] ## @@ -2383,7 +2386,7 @@ Remote reads are not allowed to use namespaces. stmts_term: ID FETCH AND CID WITH ## -## Ends in an error in state: 289. +## Ends in an error in state: 292. ## ## sident -> CID . PERIOD ID [ AS ] ## stmt -> ID FETCH AND CID . option(bcfetch_args) [ SEMICOLON EOF END BAR ] @@ -2396,7 +2399,7 @@ Ends in an error in state: 283. stmts_term: ID FETCH AND EXISTS ID PERIOD ID WITH ## -## Ends in an error in state: 287. +## Ends in an error in state: 290. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID PERIOD ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2408,7 +2411,7 @@ Ends in an error in state: 281. stmts_term: ID FETCH AND EXISTS ID PERIOD WITH ## -## Ends in an error in state: 286. +## Ends in an error in state: 289. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID PERIOD . ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2420,7 +2423,7 @@ Ends in an error in state: 280. stmts_term: ID FETCH AND EXISTS ID WITH ## -## Ends in an error in state: 285. +## Ends in an error in state: 288. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS ID . PERIOD ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2432,7 +2435,7 @@ Ends in an error in state: 279. stmts_term: ID FETCH AND EXISTS WITH ## -## Ends in an error in state: 284. +## Ends in an error in state: 287. ## ## remote_fetch_stmt -> ID FETCH AND EXISTS . ID PERIOD ID nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## @@ -2444,7 +2447,7 @@ Ends in an error in state: 278. stmts_term: ID FETCH AND ID PERIOD ID WITH ## -## Ends in an error in state: 281. +## Ends in an error in state: 284. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD ID . nonempty_list(map_access) [ SEMICOLON EOF END BAR ] ## sident -> ID . [ SEMICOLON EOF END BAR ] @@ -2457,7 +2460,7 @@ Ends in an error in state: 275. stmts_term: ID FETCH AND ID PERIOD LPAREN SPID WITH ## -## Ends in an error in state: 279. +## Ends in an error in state: 282. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD LPAREN sident . RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2469,7 +2472,7 @@ Ends in an error in state: 273. stmts_term: ID FETCH AND ID PERIOD LPAREN WITH ## -## Ends in an error in state: 278. +## Ends in an error in state: 281. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD LPAREN . sident RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2481,7 +2484,7 @@ Ends in an error in state: 272. stmts_term: ID FETCH AND ID PERIOD WITH ## -## Ends in an error in state: 277. +## Ends in an error in state: 280. ## ## remote_fetch_stmt -> ID FETCH AND ID PERIOD . sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND ID PERIOD . LPAREN sident RPAREN [ SEMICOLON EOF END BAR ] @@ -2495,7 +2498,7 @@ Ends in an error in state: 271. stmts_term: ID FETCH AND ID WITH ## -## Ends in an error in state: 276. +## Ends in an error in state: 279. ## ## remote_fetch_stmt -> ID FETCH AND ID . PERIOD sident [ SEMICOLON EOF END BAR ] ## remote_fetch_stmt -> ID FETCH AND ID . PERIOD LPAREN sident RPAREN [ SEMICOLON EOF END BAR ] @@ -2510,7 +2513,7 @@ Either blockchain state variable or remote field read expected. stmts_term: ID FETCH AND SPID AS CID UNDERSCORE ## -## Ends in an error in state: 300. +## Ends in an error in state: 303. ## ## address_typ -> CID . WITH END [ SEMICOLON EOF END BAR ] ## address_typ -> CID . WITH CONTRACT loption(separated_nonempty_list(COMMA,address_type_field)) END [ SEMICOLON EOF END BAR ] @@ -2526,7 +2529,7 @@ Casts to non-ByStr20 types are not allowed. stmts_term: ID FETCH AND SPID AS WITH ## -## Ends in an error in state: 299. +## Ends in an error in state: 302. ## ## remote_fetch_stmt -> ID FETCH AND sident AS . address_typ [ SEMICOLON EOF END BAR ] ## @@ -2538,7 +2541,7 @@ Ends in an error in state: 285. stmts_term: ID FETCH AND SPID PERIOD WITH ## -## Ends in an error in state: 274. +## Ends in an error in state: 277. ## ## remote_fetch_stmt -> ID FETCH AND SPID PERIOD . SPID [ SEMICOLON EOF END BAR ] ## @@ -2550,7 +2553,7 @@ Ends in an error in state: 268. stmts_term: ID FETCH AND SPID WITH ## -## Ends in an error in state: 273. +## Ends in an error in state: 276. ## ## remote_fetch_stmt -> ID FETCH AND SPID . PERIOD SPID [ SEMICOLON EOF END BAR ] ## sident -> SPID . [ AS ] @@ -2563,7 +2566,7 @@ Ends in an error in state: 267. lmodule: SCILLA_VERSION WITH ## -## Ends in an error in state: 361. +## Ends in an error in state: 364. ## ## lmodule -> SCILLA_VERSION . NUMLIT imports library EOF [ # ] ## @@ -2670,7 +2673,7 @@ match-expression is probably missing `end` keyword. cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN FIELD ID COLON TID EQ STRING WITH ## -## Ends in an error in state: 348. +## Ends in an error in state: 351. ## ## list(field) -> field . list(field) [ TRANSITION PROCEDURE EOF ] ## @@ -2893,7 +2896,7 @@ type_term: MAP CID LPAREN MAP CID CID TYPE ## ## Ends in an error in state: 42. ## -## t_map_value -> LPAREN t_map_value_allow_targs . RPAREN [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## t_map_value -> LPAREN t_map_value_allow_targs . RPAREN [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## LPAREN t_map_value_allow_targs @@ -2934,7 +2937,7 @@ type_term: CID WITH SPID WITH ## ## Ends in an error in state: 27. ## -## address_typ -> CID WITH SPID . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH SPID . END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH SPID @@ -2946,7 +2949,7 @@ type_term: CID WITH LIBRARY WITH ## ## Ends in an error in state: 29. ## -## address_typ -> CID WITH LIBRARY . END [ TYPE TRANSITION TID THROW TARROW SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] +## address_typ -> CID WITH LIBRARY . END [ TYPE TRANSITION TID THROW TARROW SPID SEND SEMICOLON RPAREN RBRACE PROCEDURE MATCH MAP LPAREN LET IN ID HEXLIT FORALL FIELD EVENT EQ EOF END DELETE CONTRACT COMMA CID BAR ARROW ACCEPT ] ## ## The known suffix of the stack is as follows: ## CID WITH LIBRARY @@ -2956,7 +2959,7 @@ Ends in an error in state: 29. Please report your example at https://github.com/ stmts_term: ID FETCH AND CID LPAREN WITH ## -## Ends in an error in state: 290. +## Ends in an error in state: 293. ## ## bcfetch_args -> LPAREN . separated_nonempty_list(COMMA,sident) RPAREN [ SEMICOLON EOF END BAR ] ## @@ -2968,7 +2971,7 @@ Ends in an error in state: 290. Please report your example at https://github.com stmts_term: ID FETCH AND CID LPAREN ID WITH ## -## Ends in an error in state: 291. +## Ends in an error in state: 294. ## ## separated_nonempty_list(COMMA,sident) -> sident . [ RPAREN ] ## separated_nonempty_list(COMMA,sident) -> sident . COMMA separated_nonempty_list(COMMA,sident) [ RPAREN ] @@ -2981,7 +2984,7 @@ Ends in an error in state: 291. Please report your example at https://github.com stmts_term: ID FETCH AND CID LPAREN ID COMMA WITH ## -## Ends in an error in state: 292. +## Ends in an error in state: 295. ## ## separated_nonempty_list(COMMA,sident) -> sident COMMA . separated_nonempty_list(COMMA,sident) [ RPAREN ] ## @@ -2991,27 +2994,51 @@ stmts_term: ID FETCH AND CID LPAREN ID COMMA WITH Ends in an error in state: 292. Please report your example at https://github.com/Zilliqa/scilla/issues. -cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN TARROW WITH +stmts_term: SPID WITH ## -## Ends in an error in state: 338. +## Ends in an error in state: 252. ## -## return_type -> TARROW . typ [ THROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## stmt -> SPID . ASSIGN sid [ SEMICOLON EOF END BAR ] ## ## The known suffix of the stack is as follows: -## TARROW +## SPID ## -cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN TARROW CID RPAREN +stmts_term: SPID ASSIGN WITH ## -## Ends in an error in state: 339. +## Ends in an error in state: 253. ## -## return_type -> TARROW typ . [ THROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] -## typ -> typ . TARROW typ [ THROW TARROW SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## stmt -> SPID ASSIGN . sid [ SEMICOLON EOF END BAR ] ## ## The known suffix of the stack is as follows: -## TARROW typ +## SPID ASSIGN +## + + + +cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN COLON WITH +## +## Ends in an error in state: 341. +## +## return_type -> COLON . typ [ THROW SPID SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## +## The known suffix of the stack is as follows: +## COLON +## + + + +cmodule: SCILLA_VERSION NUMLIT CONTRACT CID LPAREN RPAREN PROCEDURE CID LPAREN RPAREN COLON CID RPAREN +## +## Ends in an error in state: 342. +## +## return_type -> COLON typ . [ THROW SPID SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## typ -> typ . TARROW typ [ THROW TARROW SPID SEND MATCH ID FORALL EVENT END DELETE CID ACCEPT ] +## +## The known suffix of the stack is as follows: +## COLON typ ## ## WARNING: This example involves spurious reductions. ## This implies that, although the LR(1) items shown above provide an diff --git a/src/base/ScillaParser.mly b/src/base/ScillaParser.mly index 862a9a237..2dad03c37 100644 --- a/src/base/ScillaParser.mly +++ b/src/base/ScillaParser.mly @@ -496,7 +496,7 @@ procedure: comp_return = ret } } return_type: -| TARROW; t = typ; { t } +| COLON; t = typ; { t } transition: | TRANSITION; t = component_id; diff --git a/src/formatter/Formatter.ml b/src/formatter/Formatter.ml index 426d503b3..178beb84e 100644 --- a/src/formatter/Formatter.ml +++ b/src/formatter/Formatter.ml @@ -469,7 +469,7 @@ struct | None -> (group (comp_type ^^^ comp_name ^//^ comp_params)) | Some ty -> - (group (comp_type ^^^ comp_name ^//^ comp_params ^//^ arrow ^//^ of_type ty)) + (group (comp_type ^^^ comp_name ^//^ comp_params ^//^ colon ^//^ of_type ty)) in concat_comments comp_comments ^^ signature ^^ indent (hardline ^^ comp_body) ^^ hardline ^^ diff --git a/tests/checker/bad/return-bad1.scilla b/tests/checker/bad/return-bad1.scilla index 1b9dd8633..522ede89a 100644 --- a/tests/checker/bad/return-bad1.scilla +++ b/tests/checker/bad/return-bad1.scilla @@ -3,11 +3,11 @@ scilla_version 0 contract ReturnBad1() (* Procedure doesn't return *) -procedure no_return() -> BNum +procedure no_return() : BNum ret = _creation_block (* Error: no return *) end -procedure no_return_fixed() -> BNum +procedure no_return_fixed() : BNum ret = _creation_block; _return := ret (* OK *) end diff --git a/tests/checker/bad/return-bad2.scilla b/tests/checker/bad/return-bad2.scilla index a5783bd7c..40932add1 100644 --- a/tests/checker/bad/return-bad2.scilla +++ b/tests/checker/bad/return-bad2.scilla @@ -4,7 +4,7 @@ scilla_version 0 contract ReturnBad2() -procedure match_no_ret(a: Bool) -> BNum +procedure match_no_ret(a: Bool) : BNum match a with | True => ret = _creation_block; @@ -14,7 +14,7 @@ procedure match_no_ret(a: Bool) -> BNum (* Error: no return *) end end -procedure match_no_ret_fixed(a: Bool) -> BNum +procedure match_no_ret_fixed(a: Bool) : BNum match a with | True => ret = _creation_block; diff --git a/tests/checker/bad/return-bad3.scilla b/tests/checker/bad/return-bad3.scilla index 1548ed06c..cc8871692 100644 --- a/tests/checker/bad/return-bad3.scilla +++ b/tests/checker/bad/return-bad3.scilla @@ -4,12 +4,12 @@ scilla_version 0 contract ReturnBad3() -procedure dead_code() -> BNum +procedure dead_code() : BNum ret = _creation_block; _return := ret; dead = _creation_block (* Error *) end -procedure dead_code_fixed() -> BNum +procedure dead_code_fixed() : BNum ret = _creation_block; _return := ret end diff --git a/tests/checker/bad/return-bad4.scilla b/tests/checker/bad/return-bad4.scilla index 102baef87..a10f38a30 100644 --- a/tests/checker/bad/return-bad4.scilla +++ b/tests/checker/bad/return-bad4.scilla @@ -3,7 +3,7 @@ scilla_version 0 contract ReturnBad4 () (* Dead code after the return statement in match arms is forbidden *) -procedure dead_code_match (a : Bool) -> BNum +procedure dead_code_match (a : Bool) : BNum match a with | True => ret = _creation_block; @@ -14,7 +14,7 @@ procedure dead_code_match (a : Bool) -> BNum end; dead = _creation_block (* Error *) end -procedure dead_code_match_fixed (a : Bool) -> BNum +procedure dead_code_match_fixed (a : Bool) : BNum match a with | True => ret = _creation_block; diff --git a/tests/checker/bad/return-bad5.scilla b/tests/checker/bad/return-bad5.scilla index 6f976bcdc..45e690173 100644 --- a/tests/checker/bad/return-bad5.scilla +++ b/tests/checker/bad/return-bad5.scilla @@ -2,7 +2,7 @@ scilla_version 0 contract ReturnBad5() -procedure nested_match_no_ret(a: Bool, b: Bool) -> BNum +procedure nested_match_no_ret(a: Bool, b: Bool) : BNum match a with | True => ret = _creation_block; @@ -18,7 +18,7 @@ procedure nested_match_no_ret(a: Bool, b: Bool) -> BNum end end end -procedure nested_match_no_ret_fixed(a: Bool, b: Bool) -> BNum +procedure nested_match_no_ret_fixed(a: Bool, b: Bool) : BNum match a with | True => ret = _creation_block; diff --git a/tests/checker/bad/return-bad6.scilla b/tests/checker/bad/return-bad6.scilla index d9a7a82f1..c23a2b16b 100644 --- a/tests/checker/bad/return-bad6.scilla +++ b/tests/checker/bad/return-bad6.scilla @@ -4,7 +4,7 @@ scilla_version 0 contract ReturnBad6() -procedure dead_code_in_match(a: Bool, b: Bool) -> BNum +procedure dead_code_in_match(a: Bool, b: Bool) : BNum match a with | True => ret = _creation_block; @@ -21,7 +21,7 @@ procedure dead_code_in_match(a: Bool, b: Bool) -> BNum end end end -procedure dead_code_in_match_fixed(a: Bool, b: Bool) -> BNum +procedure dead_code_in_match_fixed(a: Bool, b: Bool) : BNum match a with | True => ret = _creation_block; diff --git a/tests/checker/bad/return-bad7.scilla b/tests/checker/bad/return-bad7.scilla index 65097100e..533114c91 100644 --- a/tests/checker/bad/return-bad7.scilla +++ b/tests/checker/bad/return-bad7.scilla @@ -6,6 +6,6 @@ contract ReturnBad7 () procedure test (x : ByStr20 with contract field x : Uint128 end) - -> ByStr20 with contract field x : Uint128, field y : Bool end + : ByStr20 with contract field x : Uint128, field y : Bool end _return := x end diff --git a/tests/checker/good/return-1.scilla b/tests/checker/good/return-1.scilla index 85fd77857..341f800d8 100644 --- a/tests/checker/good/return-1.scilla +++ b/tests/checker/good/return-1.scilla @@ -6,6 +6,6 @@ contract ReturnGood1 () procedure test (x : ByStr20 with contract field x : Uint128, field y : Bool end) - -> ByStr20 with contract field x : Uint128 end + : ByStr20 with contract field x : Uint128 end _return := x end diff --git a/tests/contracts/dead_code_test8.scilla b/tests/contracts/dead_code_test8.scilla index 772f7134e..3f29c3195 100644 --- a/tests/contracts/dead_code_test8.scilla +++ b/tests/contracts/dead_code_test8.scilla @@ -4,12 +4,12 @@ library Dead8 contract Dead8 () -procedure pr1() -> Bool +procedure pr1() : Bool res = True; _return := res end -procedure pr2(a: Bool) -> Bool +procedure pr2(a: Bool) : Bool _return := a end diff --git a/tests/contracts/return-1.scilla b/tests/contracts/return-1.scilla index 3bf3ad1b6..f8183e343 100644 --- a/tests/contracts/return-1.scilla +++ b/tests/contracts/return-1.scilla @@ -8,7 +8,7 @@ contract Return1() field f : Int32 = Int32 0 -procedure return_one() -> Int32 +procedure return_one() : Int32 a = one; _return := a end @@ -26,12 +26,12 @@ procedure forbid_negative_f() end end -procedure id(x: Int32) -> Int32 +procedure id(x: Int32) : Int32 forbid_negative_f; _return := x end -procedure add(lhs: Int32, rhs: Int32) -> Int32 +procedure add(lhs: Int32, rhs: Int32) : Int32 lhs_ = id lhs; s = builtin add lhs_ rhs; _return := s diff --git a/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla b/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla index 0449590ef..c8f40f703 100644 --- a/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla +++ b/tests/formatter/ast_does_not_change.t/procedure-return-1.scilla @@ -8,16 +8,16 @@ contract Return1() field f : Uint32 = Uint32 0 -procedure return_one() -> Uint32 +procedure return_one() : Uint32 a = one; _return := a end -procedure id(x: Uint32) -> Uint32 +procedure id(x: Uint32) : Uint32 _return := x end -procedure add(lhs: Uint32, rhs: Uint32) -> Uint32 +procedure add(lhs: Uint32, rhs: Uint32) : Uint32 s = builtin add lhs rhs; _return := s end diff --git a/tests/formatter/look_and_feel/return.t/return.scilla b/tests/formatter/look_and_feel/return.t/return.scilla index efeb56935..bfbed42fd 100644 --- a/tests/formatter/look_and_feel/return.t/return.scilla +++ b/tests/formatter/look_and_feel/return.t/return.scilla @@ -9,12 +9,12 @@ procedure no_return() _return := a end -procedure incorrect_return_type() -> (String) +procedure incorrect_return_type() : (String) a = _creation_block; _return := a end -procedure return_1() -> BNum +procedure return_1() : BNum a = _creation_block; _return := a end From fe65606b0d27675774432b09660339ad662e7072 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 10 Jan 2023 11:43:03 +0700 Subject: [PATCH 39/41] fix(sc): Error message --- src/base/SanityChecker.ml | 2 +- tests/checker/bad/gold/return-bad2.scilla.gold | 2 +- tests/checker/bad/gold/return-bad5.scilla.gold | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/SanityChecker.ml b/src/base/SanityChecker.ml index 008d68868..5f0466748 100644 --- a/src/base/SanityChecker.ml +++ b/src/base/SanityChecker.ml @@ -927,7 +927,7 @@ struct fail1 ~kind: "Every arm of the match statement must return because \ - one of arms returns" + one of the arms returns" (ER.get_loc (get_rep id)) else pure @@ ()) in diff --git a/tests/checker/bad/gold/return-bad2.scilla.gold b/tests/checker/bad/gold/return-bad2.scilla.gold index e64d5c163..e8a4aad5f 100644 --- a/tests/checker/bad/gold/return-bad2.scilla.gold +++ b/tests/checker/bad/gold/return-bad2.scilla.gold @@ -2,7 +2,7 @@ "gas_remaining": "8000", "errors": [ { - "error_message": "Every arm of the match statement must return because one of arms returns", + "error_message": "Every arm of the match statement must return because one of the arms returns", "start_location": { "file": "checker/bad/return-bad2.scilla", "line": 8, diff --git a/tests/checker/bad/gold/return-bad5.scilla.gold b/tests/checker/bad/gold/return-bad5.scilla.gold index 7cee05f8a..e1ced8377 100644 --- a/tests/checker/bad/gold/return-bad5.scilla.gold +++ b/tests/checker/bad/gold/return-bad5.scilla.gold @@ -2,7 +2,7 @@ "gas_remaining": "8000", "errors": [ { - "error_message": "Every arm of the match statement must return because one of arms returns", + "error_message": "Every arm of the match statement must return because one of the arms returns", "start_location": { "file": "checker/bad/return-bad5.scilla", "line": 11, From 20ff9413077f9cc9a3c28b981de20585ab076705 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 17 Jan 2023 12:21:28 +0700 Subject: [PATCH 40/41] chore(typechecker): Change error message --- src/base/TypeChecker.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/TypeChecker.ml b/src/base/TypeChecker.ml index 09b690c35..8d9867b11 100644 --- a/src/base/TypeChecker.ml +++ b/src/base/TypeChecker.ml @@ -1123,7 +1123,7 @@ module ScillaTypechecker (SR : Rep) (ER : Rep) = struct fail (mk_type_error1 ~kind: - (sprintf "Type cannot be used as %s return value" + (sprintf "Type %s is not a legal return type" component_type_string) ~inst:(pp_typ_error ret_ty) (SR.get_loc (get_rep comp_name))) From f483b4c4ad11fefc347fac1c2399afe25c19cb5b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 17 Jan 2023 13:02:34 +0700 Subject: [PATCH 41/41] fix(tests): Formatter test --- tests/formatter/look_and_feel/return.t/run.t | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/formatter/look_and_feel/return.t/run.t b/tests/formatter/look_and_feel/return.t/run.t index ad2ddbb4d..93739c98d 100644 --- a/tests/formatter/look_and_feel/return.t/run.t +++ b/tests/formatter/look_and_feel/return.t/run.t @@ -1,9 +1,9 @@ $ scilla-fmt return.scilla scilla_version 0 - + library Return - - + + contract Return () @@ -11,13 +11,14 @@ a = _creation_block; _return := a end - - procedure incorrect_return_type () -> String + + procedure incorrect_return_type () : String a = _creation_block; _return := a end - - procedure return_1 () -> BNum + + procedure return_1 () : BNum a = _creation_block; _return := a end +