I have a Coq project which uses the Bits library. At some places in the code I have
From Bits Require Import bits.
At that point I always get multiple warnings of the form
Warning:
New coercion path [natAsDWORD; DWORDtoVWORD] : nat >-> VWORD is ambiguous with existing
[natAsQWORD; QWORDtoVWORD] : nat >-> VWORD. [ambiguous-paths,typechecker]
Now, my compile log is always full of warnings I really don't care about and I don't see if my code produces any important warnings.
So how do I suppress all warnings at imports, or at least these ones?
For this you can use the Set Warnings command to silence warnings.
Set Warnings "-ambiguous-paths".
From Bits Require Import bits.
Set Warnings "ambiguous-paths".
ambiguous-paths is inside the warning message itself.
I first tell it to remove it with a minus in front, and then I restore it afterwards because the command is global.
The Warnings flag is documented here.
Related
I am running a Matlab compatible script in Octave, so I was awaiting few warnings concerning the '&' and '|' commands and others, so I added the "warning('all','off')" in my now Octave script, but it doesn't seem to do anything... I don't get it, I still get the same warnings!
Any ideas how to solve this please?
PS: I am running the Octave script in batch mode.
It should be warning('off','all') or just warning('off'), your arguments are inverted.
Docs: https://octave.sourceforge.io/octave/function/warning.html
warning ("off", id)
If the first argument is "on" or "off", set the state of a particular warning using the identifier id. If the first argument is "query", query the state of this warning instead. If the identifier is omitted, a value of "all" is assumed.
Obligatory note that it's probably a better idea to address the warnings than turn them off, and that you should at least re-enable the warnings after specific functions where you want to ignore them.
In Common Lisp with ASDF what is the difference between the define-package in uiop/package and the defpackage macro?
UIOP's one has more clauses.
https://common-lisp.net/project/asdf/uiop.html#UIOP_002fPACKAGE
define-package supports the following keywords: use, shadow, shadowing-import-from, import-from, export, intern -- as per cl:defpackage.
those are the same ones. But the rest of the docstring introduces more of them: recycle, mix, reexport…
I have used reexport which makes the following easier: you don't want to fully use package A (for example, Alexandria). You want to import a couple symbols (easy, with import-from), and you also want to export them (easy too, with export). But in doing so, you had to write the symbols twice. reexport saves duplication.
I heard some complains that defpackage would fail to reload a package in some situations, and define-package worked fine, but I didn't encounter this situation.
(edit): another difference: let's say you ":use" a package in your defpackage definition. Now you erase that line and you compile the package definition again. Your Lisp gives you a warning, telling that your package "also uses the following packages" and lists the one you removed from the definition. You removed the line, but the package still "uses" what you wanted to remove. You can check with (describe (find-package :my-package)).
Do the same with UIOP's define-package: you don't have warnings and your package doesn't "use" the one you removed from the definition anymore, as expected.
I'm looking for a lint for Perl, something that would catch dead code and other potential problems. Any suggestions?
I have
use strict;
use warnings;
already but I'd like to have more.
Perl::Critic is your friend. I use Test::Perl::Critic and build it into my code's author tests
Perl doesn't have a direct equivalent to lint. A large part of the reason for that is that Perl doesn't provide quite as many ways to hang yourself as C does. The basic version of "lint" for Perl is this:
perl -Mstrict [-Mdiagnostics] -cw <file>
This causes perl to compile (but not run) the specified file with strictures and warnings turned on. You can use diagnostics if you want more verbose messages or leave it out if the terse ones are enough for you.
If you want something more try using Perl::Critic, but be aware that this isn't really lint, either. lint primarily concerns itself with errors (e.g. things that would prevent compilation, trigger runtime errors, be non-portable, rely on undefined behavior, etc.). Perl::Critic is more focused on enforcement of coding standards. While there is some overlap they're very different things.
Use B::Lint. You can use it on command line by calling O module with Lint as argument, e.g.:
you#there:~/sandbox$ perl -MO=Lint Some.pm
Implicit scalar context for array in logical and (&&) at Some.pm line 121
Implicit scalar context for array in conditional expression at Some.pm line 49
Implicit scalar context for array in logical and (&&) at Some.pm line 132
Some.pm syntax OK
In addition to Perl::Critic you might want to look at the newer Perl::Lint.
How can I locate unused variables and/or dead code in Perl? This can easily be done in Java with an IDE. Can it be done in Perl?
This is a single stand-alone script and I will spot any variables that might be used in one of the requires.
Perl::Critic is a comprehensive package for source-code standards checking. It's capable of finding unused variables and unreachable code among many other things.
See warnings::unused.
This pragmatic module extends lexical warnings to complain about unused variables.
It produces warnings when a my variable or state variable is unused aside from its declaration.
The compiler complains about this, after I activated all kind of warnings:
For MyApp_Prefix.pch the compiler says:
warning: -Wuninitialized is not
supported without -O
What does that mean?
And for the uninitiated (like me), go to the Build Settings panel and filter the list for "Uninitialized Automatic Variables" then flip the flag to "No" to disable this warning. If your project file is selected this will apply across all build targets, or you can select a specific build target and change it per target.
In plain English, the compiler is complaining that it cannot check for uninitialized variables unless you turn on compiler optimization.
Chances are that it doesn't do quite such an exhaustive code path analysis if the optimizer is turned off and thus doesn't have all the necessary data to work out if a certain variable is uninitialized or not.
Simplest fix for the complaint is to turn off the warning for non-optimized builds and ensure that it's turned on for optimized release builds.
Turn on compiler optimizations.