[vala] codegen: Do not try to unbox a GValue from a GValue



commit 7d9fcdb4184f9d519c21ceb41154da0a3172079d
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri Sep 2 14:02:36 2011 +0200

    codegen: Do not try to unbox a GValue from a GValue
    
    Fixes bug 658048.

 codegen/valaccodebasemodule.vala |    2 +-
 tests/Makefile.am                |    1 +
 tests/structs/bug658048.vala     |    4 ++++
 3 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 76fc9d6..5b66896 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4462,7 +4462,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	}
 
 	public CCodeExpression? try_cast_value_to_type (CCodeExpression ccodeexpr, DataType from, DataType to, Expression? expr = null) {
-		if (from == null || gvalue_type == null || from.data_type != gvalue_type || get_ccode_type_id (to) == "") {
+		if (from == null || gvalue_type == null || from.data_type != gvalue_type || to.data_type == gvalue_type || get_ccode_type_id (to) == "") {
 			return null;
 		}
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d1b1491..751766d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,6 +73,7 @@ TESTS = \
 	structs/bug654646.vala \
 	structs/bug654753.vala \
 	structs/bug656693.vala \
+	structs/bug658048.vala \
 	delegates/delegates.vala \
 	delegates/bug539166.vala \
 	delegates/bug595610.vala \
diff --git a/tests/structs/bug658048.vala b/tests/structs/bug658048.vala
new file mode 100644
index 0000000..dda3b0e
--- /dev/null
+++ b/tests/structs/bug658048.vala
@@ -0,0 +1,4 @@
+void main () {
+	Value a = 10;
+	bool res = a == a;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]