[m-rev.] for post-commit review: shut up some C# warnings
Peter Wang
novalazy at gmail.com
Fri Mar 11 15:48:02 AEDT 2022
On Fri, 11 Mar 2022 10:20:29 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> For review by anyone.
>
> Zoltan.
> Fix C# "declared/assigned but not used" warnings.
>
> compiler/mlds_to_cs_stmt.m:
> Keep warnings disabled on all components of the implementation
> of a foreign_proc *except* the component actually written by users.
> Specifically, we want to keep "declared/assigned but not used" warnings
> disabled in the code that (a) declares and then (b) initializes
> the input arguments of a foreign_proc that the foreign_proc's body
> ignores.
>
> library/io.file.m:
> Turn the warnings off for a piece of code that ignores the details
> of an exception.
That's fine.
> diff --git a/library/io.file.m b/library/io.file.m
> index a722fcc44..7f70d1ef3 100644
> --- a/library/io.file.m
> +++ b/library/io.file.m
> @@ -1603,6 +1603,7 @@ get_temp_directory(Dir, !IO) :-
> [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe,
> may_not_duplicate],
> "
> +#pragma warning disable 162, 168, 169, 219, 1717
> try {
> Dir = System.IO.Path.GetTempPath();
> OK = (Dir != null) ? 1 : 0;
> @@ -1610,6 +1611,7 @@ get_temp_directory(Dir, !IO) :-
> Dir = null;
> OK = 0;
> }
> +#pragma warning restore
> ").
I pushed a more direct fix for the unused variable warning (168).
If it breaks some older C# compiler that we supposedly support then it
can be reverted easily.
diff --git a/library/io.file.m b/library/io.file.m
index 7f70d1ef3..61a0fc1de 100644
--- a/library/io.file.m
+++ b/library/io.file.m
@@ -1603,15 +1603,13 @@ get_temp_directory(Dir, !IO) :-
[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe,
may_not_duplicate],
"
-#pragma warning disable 162, 168, 169, 219, 1717
try {
Dir = System.IO.Path.GetTempPath();
OK = (Dir != null) ? 1 : 0;
- } catch (System.Exception _) {
+ } catch (System.Exception) {
Dir = null;
OK = 0;
}
-#pragma warning restore
").
Peter
More information about the reviews
mailing list