Add test for the unused const warning

This commit is contained in:
Gaith Hallak 2022-12-18 22:43:04 +03:00
parent be7133dec7
commit e756f935f2
2 changed files with 20 additions and 2 deletions

View File

@ -289,7 +289,9 @@ warnings() ->
<<?PosW(60, 5) <<?PosW(60, 5)
"The function `dec` is defined but never used.">>, "The function `dec` is defined but never used.">>,
<<?PosW(73, 9) <<?PosW(73, 9)
"The definition of `const` shadows an older definition at line 70, column 3.">> "The definition of `const` shadows an older definition at line 70, column 3.">>,
<<?PosW(84, 7)
"The constant `c` is defined but never used.">>
]). ]).
failing_contracts() -> failing_contracts() ->
@ -860,7 +862,9 @@ failing_contracts() ->
<<?Pos(60, 5) <<?Pos(60, 5)
"The function `dec` is defined but never used.">>, "The function `dec` is defined but never used.">>,
<<?Pos(73, 9) <<?Pos(73, 9)
"The definition of `const` shadows an older definition at line 70, column 3.">> "The definition of `const` shadows an older definition at line 70, column 3.">>,
<<?Pos(84, 7)
"The constant `c` is defined but never used.">>
]) ])
, ?TYPE_ERROR(polymorphism_contract_interface_recursive, , ?TYPE_ERROR(polymorphism_contract_interface_recursive,
[<<?Pos(1,24) [<<?Pos(1,24)

View File

@ -72,3 +72,17 @@ namespace ShadowingConst =
function f() = function f() =
let const = 2 let const = 2
const const
namespace UnusedConstNamespace =
// No warnings should be shown even though const is not used
let const = 1
contract UnusedConstContract =
// Only `c` should show a warning because it is never used in the contract
let a = 1
let b = 2
let c = 3
entrypoint f() =
// Both normal access and qualified access should prevent the unused const warning
a + UnusedConstContract.b