[m-rev.] diff: passing null in wrong places in java code

Peter Wang novalazy at gmail.com
Thu May 21 17:56:36 AEST 2009


Branches: main

compiler/mlds_to_java.m:
        Fix a bug where generated Java code could pass `null' to a function
        where a non-reference type was required.

diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m
index 6ffdc54..132c0ad 100644
--- a/compiler/mlds_to_java.m
+++ b/compiler/mlds_to_java.m
@@ -3511,8 +3511,9 @@ output_rval_const(mlconst_code_addr(CodeAddr), !IO) :-
 output_rval_const(mlconst_data_addr(DataAddr), !IO) :-
     mlds_output_data_addr(DataAddr, !IO).

-output_rval_const(mlconst_null(_), !IO) :-
-   io.write_string("null", !IO).
+output_rval_const(mlconst_null(Type), !IO) :-
+    Initializer = get_java_type_initializer(Type),
+    io.write_string(Initializer, !IO).

 %-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list