diff options
author | Juerg Billeter <j@bitron.ch> | 2008-04-14 18:16:48 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2008-04-14 18:16:48 +0000 |
commit | 9a47bfea4556af21cdd42d2faca57b9ee1e3c078 (patch) | |
tree | 194c166504b474ccee79de4f7d6a62762f4f4c2e | |
parent | 27afedc0a84382bfc3d4040a5c0e62bb70e72fa6 (diff) | |
download | vala-9a47bfea4556af21cdd42d2faca57b9ee1e3c078.tar.gz |
report error when using null literal as default expression of non-null
2008-04-14 Juerg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: report error when using null
literal as default expression of non-null parameter,
fixes bug 528021
* gee/readonlycollection.vala, gee/readonlylist.vala,
gee/readonlymap.vala, gee/readonlyset.vala, vala/valascope.vala,
ccode/valaccodeforstatement.vala, ccode/valaccodewhilestatement.vala,
vapigen/valavapicheck.vala, vapi/glib-2.0.vapi: fix revealed bugs
svn path=/trunk/; revision=1226
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | ccode/valaccodeforstatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodewhilestatement.vala | 4 | ||||
-rw-r--r-- | gee/readonlycollection.vala | 2 | ||||
-rw-r--r-- | gee/readonlylist.vala | 2 | ||||
-rw-r--r-- | gee/readonlymap.vala | 2 | ||||
-rw-r--r-- | gee/readonlyset.vala | 2 | ||||
-rw-r--r-- | vala/valascope.vala | 2 | ||||
-rw-r--r-- | vala/valasemanticanalyzer.vala | 10 | ||||
-rw-r--r-- | vapi/glib-2.0.vapi | 4 | ||||
-rw-r--r-- | vapigen/valavapicheck.vala | 2 |
11 files changed, 33 insertions, 12 deletions
@@ -1,5 +1,16 @@ 2008-04-14 Jürg Billeter <j@bitron.ch> + * vala/valasemanticanalyzer.vala: report error when using null + literal as default expression of non-null parameter, + fixes bug 528021 + + * gee/readonlycollection.vala, gee/readonlylist.vala, + gee/readonlymap.vala, gee/readonlyset.vala, vala/valascope.vala, + ccode/valaccodeforstatement.vala, ccode/valaccodewhilestatement.vala, + vapigen/valavapicheck.vala, vapi/glib-2.0.vapi: fix revealed bugs + +2008-04-14 Jürg Billeter <j@bitron.ch> + * vala/valaparser.vala: fix infinite loop on invalid syntax, fixes bug 528017 diff --git a/ccode/valaccodeforstatement.vala b/ccode/valaccodeforstatement.vala index 03ca7febb..664ec7396 100644 --- a/ccode/valaccodeforstatement.vala +++ b/ccode/valaccodeforstatement.vala @@ -1,6 +1,6 @@ /* valaccodeforstatement.vala * - * Copyright (C) 2006-2007 Jürg Billeter + * Copyright (C) 2006-2008 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -40,7 +40,7 @@ public class Vala.CCodeForStatement : CCodeStatement { private Gee.List<CCodeExpression> initializer = new ArrayList<CCodeExpression> (); private Gee.List<CCodeExpression> iterator = new ArrayList<CCodeExpression> (); - public CCodeForStatement (CCodeExpression condition, CCodeStatement body = null) { + public CCodeForStatement (CCodeExpression condition, CCodeStatement? body = null) { this.body = body; this.condition = condition; } diff --git a/ccode/valaccodewhilestatement.vala b/ccode/valaccodewhilestatement.vala index 1335fc539..2d1cc8f0a 100644 --- a/ccode/valaccodewhilestatement.vala +++ b/ccode/valaccodewhilestatement.vala @@ -1,6 +1,6 @@ /* valaccodewhilestatement.vala * - * Copyright (C) 2006-2007 Jürg Billeter + * Copyright (C) 2006-2008 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,7 +36,7 @@ public class Vala.CCodeWhileStatement : CCodeStatement { */ public CCodeStatement body { get; set; } - public CCodeWhileStatement (CCodeExpression cond, CCodeStatement stmt = null) { + public CCodeWhileStatement (CCodeExpression cond, CCodeStatement? stmt = null) { condition = cond; body = stmt; } diff --git a/gee/readonlycollection.vala b/gee/readonlycollection.vala index c54226e42..e0ec5637a 100644 --- a/gee/readonlycollection.vala +++ b/gee/readonlycollection.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> { private Collection<G> _collection; - public ReadOnlyCollection (Collection<G> collection = null) { + public ReadOnlyCollection (Collection<G>? collection = null) { this.collection = collection; } diff --git a/gee/readonlylist.vala b/gee/readonlylist.vala index 83efd6f1b..27205213e 100644 --- a/gee/readonlylist.vala +++ b/gee/readonlylist.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlyList<G> : Object, Iterable<G>, Collection<G>, List<G> { private List<G> _list; - public ReadOnlyList (List<G> list = null) { + public ReadOnlyList (List<G>? list = null) { this.list = list; } diff --git a/gee/readonlymap.vala b/gee/readonlymap.vala index cba3a2d21..b891189e9 100644 --- a/gee/readonlymap.vala +++ b/gee/readonlymap.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> { private Map<K,V> _map; - public ReadOnlyMap (Map<K,V> map = null) { + public ReadOnlyMap (Map<K,V>? map = null) { this.map = map; } diff --git a/gee/readonlyset.vala b/gee/readonlyset.vala index ecf64d933..0439c8c24 100644 --- a/gee/readonlyset.vala +++ b/gee/readonlyset.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlySet<G> : Object, Iterable<G>, Collection<G>, Set<G> { private Set<G> _set; - public ReadOnlySet (Set<G> set = null) { + public ReadOnlySet (Set<G>? set = null) { this.set = set; } diff --git a/vala/valascope.vala b/vala/valascope.vala index ac0388971..066ae0fb5 100644 --- a/vala/valascope.vala +++ b/vala/valascope.vala @@ -44,7 +44,7 @@ public class Vala.Scope : Object { * * @return newly created scope */ - public Scope (Symbol owner = null) { + public Scope (Symbol? owner = null) { this.owner = owner; } diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 791a7223c..a8a7aea18 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -533,6 +533,16 @@ public class Vala.SemanticAnalyzer : CodeVisitor { public override void visit_formal_parameter (FormalParameter p) { p.accept_children (this); + if (p.default_expression != null) { + if (p.default_expression is NullLiteral + && !p.type_reference.nullable + && !p.type_reference.is_out) { + p.error = true; + Report.error (p.source_reference, "`null' incompatible with parameter type `%s`".printf (p.type_reference.to_string ())); + return; + } + } + if (!p.ellipsis) { if (!p.is_internal_symbol ()) { current_source_file.add_type_dependency (p.type_reference, SourceFileDependencyType.HEADER_SHALLOW); diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index fe2aa2bb4..52347736c 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -1209,7 +1209,7 @@ namespace GLib { } public class Thread { - public static void init (ThreadFunctions vtable = null); + public static void init (ThreadFunctions? vtable = null); public static bool supported (); public static weak Thread create (ThreadFunc func, bool joinable) throws ThreadError; public static weak Thread create_full (ThreadFunc func, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError; @@ -1502,7 +1502,7 @@ namespace GLib { public static string to_utf8 (string opsysstring, out ulong bytes_read, out ulong bytes_written) throws ConvertError; public static string from_utf8 (string utf8string, long len, out ulong bytes_read, out ulong bytes_written) throws ConvertError; public static string from_uri (string uri, out string hostname = null) throws ConvertError; - public static string to_uri (string filename, string hostname = null) throws ConvertError; + public static string to_uri (string filename, string? hostname = null) throws ConvertError; public static string display_name (string filename); public static string display_basename (string filename); } diff --git a/vapigen/valavapicheck.vala b/vapigen/valavapicheck.vala index a066cc5d3..be9bffaf0 100644 --- a/vapigen/valavapicheck.vala +++ b/vapigen/valavapicheck.vala @@ -49,7 +49,7 @@ class Vala.VAPICheck : Object { } } - private void add_symbol (string name, string separator = null) { + private void add_symbol (string name, string? separator = null) { if (null != separator) { string fullname = get_scope () + separator + name; |