[vala/staging: 2/2] Forbid var declaration with null initializer
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 2/2] Forbid var declaration with null initializer
- Date: Sat, 17 Sep 2016 15:27:18 +0000 (UTC)
commit efb50e48c505d673586c89ebecb47a8a82724b5b
Author: Luca Bruno <lucabru src gnome org>
Date: Fri May 27 15:11:35 2011 +0200
Forbid var declaration with null initializer
https://bugzilla.gnome.org/show_bug.cgi?id=639990
tests/Makefile.am | 1 +
tests/basic-types/bug639990.test | 5 +++++
vala/valalocalvariable.vala | 2 +-
3 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ca2a52c..b207e84 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,6 +28,7 @@ TESTS = \
basic-types/bug596637.vala \
basic-types/bug596785.vala \
basic-types/bug632322.vala \
+ basic-types/bug639990.test \
basic-types/bug643612.vala \
basic-types/bug644046.vala \
basic-types/bug647222.vala \
diff --git a/tests/basic-types/bug639990.test b/tests/basic-types/bug639990.test
new file mode 100644
index 0000000..38a59ae
--- /dev/null
+++ b/tests/basic-types/bug639990.test
@@ -0,0 +1,5 @@
+Invalid Code
+
+void main () {
+ var foo = null;
+}
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index a7979f7..14eec0c 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -112,7 +112,7 @@ public class Vala.LocalVariable : Variable {
Report.error (source_reference, "var declaration not allowed without
initializer");
return false;
}
- if (initializer.value_type == null) {
+ if (initializer.value_type == null || initializer.value_type is NullType) {
error = true;
Report.error (source_reference, "var declaration not allowed with non-typed
initializer");
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]