From: Juerg Billeter Date: Mon, 14 Apr 2008 18:16:48 +0000 (+0000) Subject: report error when using null literal as default expression of non-null X-Git-Tag: VALA_0_3_1~76 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a47bfea4556af21cdd42d2faca57b9ee1e3c078;p=platform%2Fupstream%2Fvala.git report error when using null literal as default expression of non-null 2008-04-14 Juerg Billeter * 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 --- diff --git a/ChangeLog b/ChangeLog index a624c32..2d74b89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2008-04-14 Jürg Billeter + * 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 + * vala/valaparser.vala: fix infinite loop on invalid syntax, fixes bug 528017 diff --git a/ccode/valaccodeforstatement.vala b/ccode/valaccodeforstatement.vala index 03ca7fe..664ec73 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 initializer = new ArrayList (); private Gee.List iterator = new ArrayList (); - 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 1335fc5..2d1cc8f 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 c54226e..e0ec563 100644 --- a/gee/readonlycollection.vala +++ b/gee/readonlycollection.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlyCollection : Object, Iterable, Collection { private Collection _collection; - public ReadOnlyCollection (Collection collection = null) { + public ReadOnlyCollection (Collection? collection = null) { this.collection = collection; } diff --git a/gee/readonlylist.vala b/gee/readonlylist.vala index 83efd6f..2720521 100644 --- a/gee/readonlylist.vala +++ b/gee/readonlylist.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlyList : Object, Iterable, Collection, List { private List _list; - public ReadOnlyList (List list = null) { + public ReadOnlyList (List? list = null) { this.list = list; } diff --git a/gee/readonlymap.vala b/gee/readonlymap.vala index cba3a2d..b891189 100644 --- a/gee/readonlymap.vala +++ b/gee/readonlymap.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlyMap : Object, Map { private Map _map; - public ReadOnlyMap (Map map = null) { + public ReadOnlyMap (Map? map = null) { this.map = map; } diff --git a/gee/readonlyset.vala b/gee/readonlyset.vala index ecf64d9..0439c8c 100644 --- a/gee/readonlyset.vala +++ b/gee/readonlyset.vala @@ -36,7 +36,7 @@ public class Gee.ReadOnlySet : Object, Iterable, Collection, Set { private Set _set; - public ReadOnlySet (Set set = null) { + public ReadOnlySet (Set? set = null) { this.set = set; } diff --git a/vala/valascope.vala b/vala/valascope.vala index ac03889..066ae0f 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 791a722..a8a7aea 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 fe2aa2b..5234773 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 a066cc5..be9bffa 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;