[vala] Fix crash on invalid constructor chain up
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Fix crash on invalid constructor chain up
- Date: Mon, 13 Sep 2010 20:20:59 +0000 (UTC)
commit 8225cc38466f363e63a4f39b83cac252f2d34a1a
Author: Jürg Billeter <j bitron ch>
Date: Mon Sep 13 22:19:39 2010 +0200
Fix crash on invalid constructor chain up
Fixes bug 628182.
vala/valasemanticanalyzer.vala | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index db788fd..576412c 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -409,9 +409,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
if (arg_it == null || !arg_it.next ()) {
if (param.initializer == null) {
- var m = (MethodType) mtype;
expr.error = true;
- Report.error (expr.source_reference, "%d missing arguments for `%s'".printf (m.get_parameters ().size - args.size, m.to_prototype_string ()));
+ var m = mtype as MethodType;
+ if (m != null) {
+ Report.error (expr.source_reference, "%d missing arguments for `%s'".printf (m.get_parameters ().size - args.size, m.to_prototype_string ()));
+ } else {
+ Report.error (expr.source_reference, "Too few arguments, method `%s' does not take %d arguments".printf (mtype.to_string (), args.size));
+ }
return false;
} else {
var invocation_expr = expr as MethodCall;
@@ -466,9 +470,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
i++;
}
} else if (!ellipsis && arg_it != null && arg_it.next ()) {
- var m = (MethodType) mtype;
expr.error = true;
- Report.error (expr.source_reference, "%d extra arguments for `%s'".printf (args.size - m.get_parameters ().size, m.to_prototype_string ()));
+ var m = mtype as MethodType;
+ if (m != null) {
+ Report.error (expr.source_reference, "%d extra arguments for `%s'".printf (args.size - m.get_parameters ().size, m.to_prototype_string ()));
+ } else {
+ Report.error (expr.source_reference, "Too many arguments, method `%s' does not take %d arguments".printf (mtype.to_string (), args.size));
+ }
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]