From 023648b5e9fcf4520319b92eb6b38eaf72edaf1f Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 11 Oct 2022 11:42:04 +0500 Subject: [PATCH] fix(dcd): Better error messages; update tests --- src/base/DeadCodeDetector.ml | 6 +++--- .../checker/good/gold/dead_code_test15.scilla.gold | 14 +++++++------- .../checker/good/gold/dead_code_test18.scilla.gold | 6 +++--- tests/contracts/dead_code_test15.scilla | 1 - 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/base/DeadCodeDetector.ml b/src/base/DeadCodeDetector.ml index c96d6cd53..03249e91d 100644 --- a/src/base/DeadCodeDetector.ml +++ b/src/base/DeadCodeDetector.ml @@ -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)) @@ -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)))) @@ -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))))))) diff --git a/tests/checker/good/gold/dead_code_test15.scilla.gold b/tests/checker/good/gold/dead_code_test15.scilla.gold index 742d6e580..57123b931 100644 --- a/tests/checker/good/gold/dead_code_test15.scilla.gold +++ b/tests/checker/good/gold/dead_code_test15.scilla.gold @@ -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, @@ -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, @@ -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 }, @@ -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 }, @@ -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 }, diff --git a/tests/checker/good/gold/dead_code_test18.scilla.gold b/tests/checker/good/gold/dead_code_test18.scilla.gold index 6645b91cc..3e5e60dcd 100644 --- a/tests/checker/good/gold/dead_code_test18.scilla.gold +++ b/tests/checker/good/gold/dead_code_test18.scilla.gold @@ -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, @@ -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, @@ -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, diff --git a/tests/contracts/dead_code_test15.scilla b/tests/contracts/dead_code_test15.scilla index 3fd4620a6..1c99d5c32 100644 --- a/tests/contracts/dead_code_test15.scilla +++ b/tests/contracts/dead_code_test15.scilla @@ -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,