diff options
author | Jürg Billeter <j@bitron.ch> | 2010-09-13 22:19:39 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2010-09-13 22:19:39 +0200 |
commit | 8225cc38466f363e63a4f39b83cac252f2d34a1a (patch) | |
tree | 6702ea648bcd83243cfa9b8be0043abfb1c7aa2d /vala/valasemanticanalyzer.vala | |
parent | 39ade29474484c0309e76441897c531df73d5d47 (diff) | |
download | vala-8225cc38466f363e63a4f39b83cac252f2d34a1a.tar.gz |
Fix crash on invalid constructor chain up
Fixes bug 628182.
Diffstat (limited to 'vala/valasemanticanalyzer.vala')
-rw-r--r-- | vala/valasemanticanalyzer.vala | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index db788fdc4..576412c37 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; } |