20

I'm writing unit tests for some contracts and in some of the tests I'm generating a warning on purpose and solc will display this warning when compiling.

Is there a way to disable warnings in solc for the purpose of a test.

Something equivalent to MSVC++

#pragma warning(push)
#pragma warning(disable : 44444)
// CODE
#pragma warning(pop)
Ismael
  • 30,570
  • 21
  • 53
  • 96
  • Solc, from my knowledge, only compiles the code. It does not deal with address checksum. – Itération 122442 Jan 12 '18 at 03:41
  • It just seems like the address provided is not matching the checksum. The error tells you everything – Itération 122442 Jan 12 '18 at 05:10
  • 2
    According to the solc's command-line help - no. Maybe you can "suppress" it by replacing the address with a uint256, and then replacing every other occurrence of a with address(a). – goodvibration Jan 17 '18 at 15:52
  • @goodvibration Yes, I know, it is bad on purpose, and I know how to fix this in particular. But the question is about how to disable an arbitrary warning for running automated tests. – Ismael Jan 18 '18 at 14:39
  • address constant a = "0x0123456789abcDEF0123456789abCDef01234568"; try this.. – Elango Elango Elango Jan 17 '18 at 06:10
  • I think you can select update version pragma compiler..remove constant and put view.0.4.18 – Elango Elango Elango Jan 11 '18 at 11:18
  • I wouldn't recommend disabling warning for solidity code. They exist for a reason which you need to take in consideration. – Tarik EN-NAKDI May 17 '18 at 15:25
  • Opening an issue on their repo and requesting this feature might be a good start, they're quite open and actually looking for user feedback extensively. – DenisM May 29 '18 at 22:53
  • I've never reported it because in my opinion it is a bad feature for most users and likely it will be misused by bad library implementors. – Ismael May 30 '18 at 02:25

2 Answers2

1

As of 24/05/2018, there is no way to natively disable the warnings the solc compiler emits. There is, however, a way to bypass those warnings by creating a wrapper.

Simply create a Node.JS application that internally uses the solcjs plugin, which is a port of solc into Node, to compile your local .sol smart contracts and filter the output of the plugin.

This is, indeed, a very unorthodox approach and muting warnings should generally be avoided.

Alex Papageorgiou
  • 670
  • 1
  • 5
  • 14
  • It is a unit test, it fails and I detect that situation and report as such. I'd want to disable it only for that case for cosmetic reasons. I never reported it because I think it is a bad feature for most users. – Ismael May 24 '18 at 18:57
1

You could also use solidity-cli which disables the warnings by default.

pubkey
  • 1,157
  • 1
  • 10
  • 15