From 86975197bb54bc57f7c4d3753b61e5c40070390a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Wed, 10 Apr 2024 13:31:42 -0400 Subject: [PATCH] fix[ux]: fix `uses` error message (#3926) when a stateless module is accidentally declared as being `used` by a user, the error message is confusing. update the error message to clarify `uses` refers to state being used. --- tests/functional/syntax/modules/test_initializers.py | 8 ++++++-- vyper/semantics/analysis/module.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/functional/syntax/modules/test_initializers.py b/tests/functional/syntax/modules/test_initializers.py index 9825e4618f..f6697afea1 100644 --- a/tests/functional/syntax/modules/test_initializers.py +++ b/tests/functional/syntax/modules/test_initializers.py @@ -915,7 +915,9 @@ def foo(): with pytest.raises(BorrowException) as e: compile_code(main, input_bundle=input_bundle) - assert e.value._message == "`lib1` is declared as used, but it is not actually used in lib2.vy!" + expected = "`lib1` is declared as used, but its state is not" + expected += " actually used in lib2.vy!" + assert e.value._message == expected assert e.value._hint == "delete `uses: lib1`" @@ -956,7 +958,9 @@ def foo(): with pytest.raises(BorrowException) as e: compile_code(main, input_bundle=input_bundle) - assert e.value._message == "`lib1` is declared as used, but it is not actually used in lib2.vy!" + expected = "`lib1` is declared as used, but its state is not " + expected += "actually used in lib2.vy!" + assert e.value._message == expected assert e.value._hint == "delete `uses: lib1`" diff --git a/vyper/semantics/analysis/module.py b/vyper/semantics/analysis/module.py index 619f4e4c10..5cb6ae4f5c 100644 --- a/vyper/semantics/analysis/module.py +++ b/vyper/semantics/analysis/module.py @@ -315,7 +315,7 @@ def validate_used_modules(self): err_list = ExceptionList() for used_module_info, uses_info in should_use.values(): msg = f"`{used_module_info.alias}` is declared as used, but " - msg += f"it is not actually used in {module_t}!" + msg += f"its state is not actually used in {module_t}!" hint = f"delete `uses: {used_module_info.alias}`" err_list.append(BorrowException(msg, uses_info.node, hint=hint))