Allow comments to ignore compiler warnings.
I would like the ability to disable compiler warnings on a per-line basis using something like comments or pragma. C++ has a mechanism to also disable comments across a block using #pragma push (disable: 1234) and #pragma pop. I'll leave it up to the language designers to decide the exact mechanism based on which one is most reasonable to implement. The key is that I need to be able to disable any single specific warning in the source code that is generating that warning.
With solc becoming more and more opinionated with its compiler warnings, there needs to be a way to disable them selectively. At the moment, we use solc compiler warnings/errors as a CI gate block but we are finding that some of the warnings should be ignored, yet we don't have a reasonable way to do this right now.
For example, we have a SafeMath library that leverages using SafeMath for <type>. This library does function overloading/shadowing so that it can have both add(uint256,uint256) and add(int256,int256) in the same library. I appreciate the warning, but I need the ability to disable it on a case-by-case basis. The same goes for a number of other warnings that have been added recently. In general I think are all very valuable, but may not be able to be applied exhaustively to all code.
This is a duplicate of #2675. Please follow up on that thread.
Note: it falsely reports overloading as shadowing and that is being fixed (also addressed in a different issue).
@axic I saw that, but it appears that discussion is around file-wide ignores, rather than per-line ignores. Are you suggesting that you think both tasks would likely be solved at the same time? Normally, when I'm running a GitHub project I prefer issues to be very specific as to the feature being requested and this feels like two separate features to me. (per line ignore and per file ignore)
Sorry I didn't pick up you are suggesting a way to disable warnings on specific lines with adding a specific marker at that (like a comment). That is of course a different issue than #2675. If so, please reopen this and explain your proposal.
However, if you read it carefully, there is a strong sentiment at the moment not to support any option to disable warnings. (We need to remove false negatives though.)
I'll propose my arguments against no-disable option in the other issue.
I have updated the description of this issue to add clarity that I'm looking for a targeted in-source mechanism for disabling, but I don't have the access rights to re-open the issue. Would you mind re-opening it for me if you believe the issue is clear enough now @axic?
Thanks, it is clear now!
+1. The compiler warnings break backwards compatibility with many external libraries. This will be a great feature to have.
Hi, there
What's this issue's status now? I'm so hopeful for this nice feature. 😺
+1 for this - it's hard when the compiler is printing warnings that you acknowledge and want to ignore. It distracts from reading the warnings that may crop up but you don't want to ignore. A comment mechanism as proposed here would allow one to express that they understand the risks.
@yarrumretep we take special care such that any warning given by the compiler can be removed by a small change to the source code. Could you please give an example where it would be easier to "remove" the warning by adding a comment instead of changing the source code to remove the risk altogether?
Actually a short term solution will be the 0.5.0 release turning most, if not all, these warnings into an error :wink:
@chriseth we are seeing Warning: The "returndatacopy" instruction is only available after the Metropolis hard fork. Before that it acts as an invalid instruction. I am happy to have been notified of this, but would like to suppress this message as we are happy to proceed understanding that limitation. Same for returndatasize, methinks.
We are also seeing Warning: Jump instructions are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch" or "for" statements instead. We are getting these from compiling Aracnid's string library - they are in functions we aren't using so we can prune them from our copy of the library. But if jump is not going to be allowed shouldn't it be deprecated and eventually removed from the language? BTW I don't have an opinion on this - just want to be able to get to a clean build when using the available features of the language.
@yarrumretep we are still debating how to handle different versions of the EVM, but I hope that we can resolve the returndatacopy issue soon - sorry that it takes so long.
Concerning jumps: Yes, please either remove the code or submit a pull request to the library turning it into code that does not use manual jumps.
We actually did deprecate them, but yes, that should probably be mentioned literally as part of the warning.
Thank you for the clarification @chriseth. Maybe you could handle the hardfork thing with a compiler flag indicating what version of the EVM you want to target. Then the returndatasize etc would error appropriately.
@yarrumretep yes, the question is basically whether we want to use a pragma or a compiler switch, but we will probably go with a compiler switch. Since this would be the first switch that affects code generation itself, it is a little tricky :)
@chriseth - interesting. BTW, we are using those opcodes to grab a string return value b/c solidity currently doesn't return strings from calls. Is this going to burn us or simply be unnecessary with future solidity versions?
We can hopefully merge the new abi decoder soon, then it will be automatic.
but you can of course also do it using inline asssembly
This has been particularly annoying since var was deprecated, since there is presently no way to implement var (,,,,,what,,evs,,,dude,) = lib.extFunc("arg"). I'd like to be able to silence these warnings until that is resolved, as it spits out a separate error for each variable (what, evs, dude) and makes it very hard to see real warnings.
Agree with getting var warning suppressed.
@celeduc can you explain why var (,,,,,what,,evs,,,dude,) = lib.extFunc("arg") cannot be done without warnings anymore? W what; E evs; D dude; (,,,,,what,,evs,,,dude,) = lib.extFunc("arg") should work.