summaryrefslogtreecommitdiff
path: root/vala/valalocalvariable.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2009-01-10 13:15:14 +0000
committerJürg Billeter <juergbi@src.gnome.org>2009-01-10 13:15:14 +0000
commit62105a45123d50b17ed0a5390b9472a0e5afdefe (patch)
tree38d2ac7287532895e5c7ea1d011daa6535699fd6 /vala/valalocalvariable.vala
parentb3c2e8688a5ad3153504c94416e0c6fd1f94838d (diff)
downloadvala-62105a45123d50b17ed0a5390b9472a0e5afdefe.tar.gz
Warn when using result variable with incompatible type to prepare possible
2009-01-10 Jürg Billeter <j@bitron.ch> * vala/valalocalvariable.vala: Warn when using result variable with incompatible type to prepare possible introduction of implicit result variable * vala/valageniescanner.vala: * vala/valascanner.vala: * vala/valasymbol.vala: Fix new warnings svn path=/trunk/; revision=2322
Diffstat (limited to 'vala/valalocalvariable.vala')
-rw-r--r--vala/valalocalvariable.vala10
1 files changed, 10 insertions, 0 deletions
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index a0e001416..cdc9b3a69 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -142,6 +142,16 @@ public class Vala.LocalVariable : Symbol {
initializer.target_type = variable_type;
}
+ if (name == "result") {
+ // warn if type of `result' variable is incompatible with return type
+ // as an implicit `result' variable might be introduced to be used
+ // by Vala postconditions and implicit checks generated by the code generated
+ if (analyzer.current_return_type == null
+ || !variable_type.compatible (analyzer.current_return_type)) {
+ Report.warning (source_reference, "result variable type incompatible with return type");
+ }
+ }
+
if (initializer != null) {
if (initializer.value_type == null) {
if (!(initializer is MemberAccess) && !(initializer is LambdaExpression)) {