From: Jürg Billeter Date: Sat, 6 Jun 2009 16:22:15 +0000 (+0200) Subject: Report error for recursive value types X-Git-Tag: 0.7.4~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fkeep-around%2Fda2d58c95f39fd142dc845f5df9cdcd55be32476;p=thirdparty%2Fvala.git Report error for recursive value types Fixes bug 584573. --- diff --git a/vala/valastruct.vala b/vala/valastruct.vala index 8f5fbcaa2..166edba43 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -690,6 +690,22 @@ public class Vala.Struct : TypeSymbol { return false; } + bool is_recursive_value_type (DataType type) { + var struct_type = type as StructValueType; + if (struct_type != null) { + var st = (Struct) struct_type.type_symbol; + if (st == this) { + return true; + } + foreach (Field f in st.fields) { + if (f.binding == MemberBinding.INSTANCE && is_recursive_value_type (f.field_type)) { + return true; + } + } + } + return false; + } + public override bool check (SemanticAnalyzer analyzer) { if (checked) { return !error; @@ -725,6 +741,12 @@ public class Vala.Struct : TypeSymbol { foreach (Field f in fields) { f.check (analyzer); + + if (f.binding == MemberBinding.INSTANCE && is_recursive_value_type (f.field_type)) { + error = true; + Report.error (f.source_reference, "Recursive value types are not allowed"); + return false; + } } foreach (Constant c in constants) {