Enable/disable language features to save gas

The optimizer currently cannot evaluate this static cases. Mainly because the value is stored in a memory location, and keccak256 reads from the location. We currently don’t have these kinds of memory optimization. I made an issue to track this: [YulOpti] Evaluate keccak256 whenever possible · Issue #11018 · ethereum/solidity · GitHub

Maybe instead of such a pragma line I’d propose a more readable one.

pragma check disable CheckFeature; // comma seperated list of checks to disable, such as arithmetic.

OTOH, maybe it would be interesting to not do that globally but more in a scope level, which would require to extend the AST but gives you finer grained control to only disable the checks where you want them to be disabled (similar to the unchecked keyword in C# or generally speaking, the unsafe keyword in rust.

+1 for pragma unchecked_arithmetic;

Compiler flags will cause an issue if some code from a library legitimately uses checked arithmetic while your own client code needs to opt out. So it could be dangerous to use such a flag in general as it requires full knowledge of imported code.