This repository was archived by the owner on Aug 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed
Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -251,9 +251,12 @@ address_typ :
251251| d = CID ; WITH ; CONTRACT ; fs = separated_list(COMMA , address_type_field); END ;
252252 { if d = " ByStr20"
253253 then
254- (* Add _this_address : ByStr20 to field list. This ensures the type is treated as a contract address *)
255254 let fs' = List. fold_left (fun acc (id , t ) ->
256- SType.IdLoc_Comp.Map. set acc ~key: id ~data: t) SType.IdLoc_Comp.Map. empty fs
255+ match SType.IdLoc_Comp.Map. add acc ~key: id ~data: t with
256+ | `Ok new_map -> new_map
257+ | `Duplicate ->
258+ raise (SyntaxError (Printf. sprintf " Duplicate field name %s in address type" (ParserIdentifier. as_string id), toLoc $ startpos(d))))
259+ SType.IdLoc_Comp.Map. empty fs
257260 in
258261 Address (ContrAddr fs')
259262 else raise (SyntaxError (" Invalid type" , toLoc $ startpos(d))) }
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ module Tests = Scilla_test.Util.DiffBasedTests (struct
3434
3535 let tests =
3636 [
37+ " address_duplicate_field.scilla" ;
38+ " address_spid_as_field.scilla" ;
3739 " bad_cast_2.scilla" ;
3840 " bad_cast_3.scilla" ;
3941 " bad_map_key_2.scilla" ;
@@ -69,6 +71,7 @@ module Tests = Scilla_test.Util.DiffBasedTests (struct
6971 " lmodule-import-cid-as-cid-with.scilla" ;
7072 " lmodule-import-cid-as-with.scilla" ;
7173 " lmodule-import-cid-with.scilla" ;
74+ " remote_read_namespace.scilla" ;
7275 " stmts_t-accept-with.scilla" ;
7376 " stmts_t-cid-with.scilla" ;
7477 " stmts_t-delete-id-with.scilla" ;
@@ -136,8 +139,6 @@ module Tests = Scilla_test.Util.DiffBasedTests (struct
136139 " type_t-map-with.scilla" ;
137140 " type_t-tid-arrow-tid-with.scilla" ;
138141 " type_t-tid-arrow-with.scilla" ;
139- " address_spid_as_field.scilla" ;
140- " remote_read_namespace.scilla" ;
141142 ]
142143
143144 let exit_code : UnixLabels.process_status = WEXITED 1
Original file line number Diff line number Diff line change 1+ scilla_version 0
2+
3+ contract DuplicateField ()
4+
5+ procedure test
6+ (
7+ a :
8+ ByStr20 with contract
9+ field a : ByStr20 with end,
10+ field b : Map (ByStr20 with end) Bool,
11+ field b : Map (ByStr20 with end) Bool
12+ end
13+ )
14+
15+ end
Original file line number Diff line number Diff line change 1+ {
2+ "errors": [
3+ {
4+ "error_message": "Syntax error: Duplicate field name b in address type",
5+ "start_location": {
6+ "file": "base/parser/bad/address_duplicate_field.scilla",
7+ "line": 8,
8+ "column": 7
9+ },
10+ "end_location": { "file": "", "line": 0, "column": 0 }
11+ }
12+ ],
13+ "warnings": []
14+ }
You can’t perform that action at this time.
0 commit comments