Skip to content

Commit

Permalink
fix(dcd): Better error messages; update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Oct 11, 2022
1 parent a644baa commit 023648b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/base/DeadCodeDetector.ml
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct
if Set.mem fields name && (not @@ Set.mem used_fields name)
then
warn1
("Unused field in the contract address type: "
("Unused field in contract address type: "
^ as_error_string id)
warning_level_dead_code
(SType.TIdentifier.get_rep id))
Expand Down Expand Up @@ -639,7 +639,7 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct
then
Set.iter unused_fields ~f:(fun f ->
warn1
("Unused field in the contract address type: "
("Unused field in contract address type: "
^ SCIdentifier.Name.as_string f)
warning_level_dead_code
(ER.get_loc (SCIdentifier.get_rep id))))
Expand Down Expand Up @@ -840,7 +840,7 @@ module DeadCodeDetector (SR : Rep) (ER : Rep) = struct
let unused_fields = Set.diff all_fields used_fields in
Set.iter unused_fields ~f:(fun f ->
warn1
("Unused field in the contract address type: "
("Unused field in contract address type: "
^ SCIdentifier.Name.as_string f)
warning_level_dead_code
(ER.get_loc (SCIdentifier.get_rep ctr.cname)))))))
Expand Down
14 changes: 7 additions & 7 deletions tests/checker/good/gold/dead_code_test15.scilla.gold
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
"warnings": [
{
"warning_message": "Unused field in the contract address type: param_unused",
"warning_message": "Unused field in contract address type: param_unused",
"start_location": {
"file": "contracts/dead_code_test15.scilla",
"line": 10,
Expand All @@ -97,17 +97,17 @@
"warning_id": 3
},
{
"warning_message": "Unused field in the contract address type: field4",
"warning_message": "Unused field in contract address type: field4",
"start_location": {
"file": "contracts/dead_code_test15.scilla",
"line": 35,
"line": 34,
"column": 13
},
"end_location": { "file": "", "line": 0, "column": 0 },
"warning_id": 3
},
{
"warning_message": "Unused field in the contract address type: unused_field",
"warning_message": "Unused field in contract address type: unused_field",
"start_location": {
"file": "contracts/dead_code_test15.scilla",
"line": 22,
Expand All @@ -120,7 +120,7 @@
"warning_message": "Unused transition parameter: contract_address",
"start_location": {
"file": "contracts/dead_code_test15.scilla",
"line": 33,
"line": 32,
"column": 5
},
"end_location": { "file": "", "line": 0, "column": 0 },
Expand All @@ -130,7 +130,7 @@
"warning_message": "Unused transition parameter: contract_address_unused",
"start_location": {
"file": "contracts/dead_code_test15.scilla",
"line": 29,
"line": 28,
"column": 5
},
"end_location": { "file": "", "line": 0, "column": 0 },
Expand All @@ -140,7 +140,7 @@
"warning_message": "Unused remote load statement to: a",
"start_location": {
"file": "contracts/dead_code_test15.scilla",
"line": 37,
"line": 36,
"column": 3
},
"end_location": { "file": "", "line": 0, "column": 0 },
Expand Down
6 changes: 3 additions & 3 deletions tests/checker/good/gold/dead_code_test18.scilla.gold
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
},
"warnings": [
{
"warning_message": "Unused field in the contract address type: a1_unused2_3",
"warning_message": "Unused field in contract address type: a1_unused2_3",
"start_location": {
"file": "contracts/dead_code_test18.scilla",
"line": 9,
Expand All @@ -129,7 +129,7 @@
"warning_id": 3
},
{
"warning_message": "Unused field in the contract address type: a1_unused1_3",
"warning_message": "Unused field in contract address type: a1_unused1_3",
"start_location": {
"file": "contracts/dead_code_test18.scilla",
"line": 9,
Expand All @@ -139,7 +139,7 @@
"warning_id": 3
},
{
"warning_message": "Unused field in the contract address type: a1_unused_1",
"warning_message": "Unused field in contract address type: a1_unused_1",
"start_location": {
"file": "contracts/dead_code_test18.scilla",
"line": 9,
Expand Down
1 change: 0 additions & 1 deletion tests/contracts/dead_code_test15.scilla
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ transition tr1(contract_address: ByStr20 with contract
b <- & contract_address.field2
end

(* Don't report unused fields. *)
transition tr2(
contract_address_unused: ByStr20 with contract
field field1: ByStr20,
Expand Down

0 comments on commit 023648b

Please sign in to comment.