[vala] Report error when field initializers may throw errors
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Report error when field initializers may throw errors
- Date: Sun, 13 Dec 2009 17:09:08 +0000 (UTC)
commit 6b07e7f6d0dece8a759b3a9d2768b0ba5ae55619
Author: Jürg Billeter <j bitron ch>
Date: Sun Dec 13 18:08:07 2009 +0100
Report error when field initializers may throw errors
vala/valamethodcall.vala | 3 +++
vala/valaobjectcreationexpression.vala | 3 +++
2 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index ab47024..8ac74a9 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -499,6 +499,9 @@ public class Vala.MethodCall : Expression {
if (may_throw) {
if (parent_node is LocalVariable || parent_node is ExpressionStatement) {
// simple statements, no side effects after method call
+ } else if (!(analyzer.current_symbol is Block)) {
+ // can't handle errors in field initializers
+ Report.error (source_reference, "Field initializers must not throw errors");
} else {
// store parent_node as we need to replace the expression in the old parent node later on
var old_parent_node = parent_node;
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 4a038ce..f0c9108 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -386,6 +386,9 @@ public class Vala.ObjectCreationExpression : Expression {
if (may_throw) {
if (parent_node is LocalVariable || parent_node is ExpressionStatement) {
// simple statements, no side effects after method call
+ } else if (!(analyzer.current_symbol is Block)) {
+ // can't handle errors in field initializers
+ Report.error (source_reference, "Field initializers must not throw errors");
} else {
// store parent_node as we need to replace the expression in the old parent node later on
var old_parent_node = parent_node;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]