From a692846647bed9c22b47ab358ea826bbfe6e9a55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Tue, 24 Oct 2006 21:01:48 +0000 Subject: [PATCH] don't crash when comparing value type with null MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2006-10-24 Jürg Billeter * vala/valasemanticanalyzer.vala: don't crash when comparing value type with null svn path=/trunk/; revision=147 --- vala/ChangeLog | 5 +++++ vala/vala/valasemanticanalyzer.vala | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/vala/ChangeLog b/vala/ChangeLog index c96e906..3e44bb8 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,5 +1,10 @@ 2006-10-24 Jürg Billeter + * vala/valasemanticanalyzer.vala: don't crash when comparing value type + with null + +2006-10-24 Jürg Billeter + * vala/valasymbolresolver.vala: don't crash on already resolved type references * vala/valasemanticanalyzer.vala: support typeof expression diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index d848922..65908ae 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -828,15 +828,19 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return (expression_type.data_type == null && expected_type.type_parameter == null); } - /* null can be cast to any reference or array type */ - if (expression_type.data_type == null && - (expected_type.type_parameter != null || - expected_type.data_type.is_reference_type () || - expected_type.reference_to_value_type || - expected_type.data_type is Array || - expected_type.data_type is Callback || - expected_type.data_type == pointer_type)) { - return true; + if (expression_type.data_type == null) { + /* null can be cast to any reference or array type */ + if (expected_type.type_parameter != null || + expected_type.data_type.is_reference_type () || + expected_type.reference_to_value_type || + expected_type.data_type is Array || + expected_type.data_type is Callback || + expected_type.data_type == pointer_type) { + return true; + } + + /* null is not compatible with any other type (i.e. value types) */ + return false; } /* temporarily ignore type parameters */ -- 2.7.4