Thrift compiler now enforces uniqueness of field identifiers
Summary: The code would either not generate, or generate code with errors, if you did this beforehand. Now it's a die-fast stop hard error since this is absolultely always a wrong thing to do.
Reviewed By: dreiss
Test Plan: Test compiling a .thrift file with a repeated field identifier in a struct or arglist.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665379 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 5d7cfcc..21828ff 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -761,6 +761,10 @@
{
pdebug("FieldList -> FieldList , Field");
$$ = $1;
+ if (!($$->validate_field($2))) {
+ yyerror("Field identifier %d for \"%s\" has already been used", $2->get_key(), $2->get_name().c_str());
+ exit(1);
+ }
$$->append($2);
}
|