THRIFT-2089 Compiler ignores duplicate typenames
Patch: Randy Abernethy
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 2d90f21..5b91a0a 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -450,6 +450,10 @@
         if (g_parent_scope != NULL) {
           g_parent_scope->add_type(g_parent_prefix + $1->get_name(), $1);
         }
+        if (! g_program->is_unique_typename($1)) {
+          yyerror("Type \"%s\" is already defined.", $1->get_name().c_str());
+          exit(1);
+        }
       }
       $$ = $1;
     }
@@ -462,6 +466,10 @@
           g_parent_scope->add_service(g_parent_prefix + $1->get_name(), $1);
         }
         g_program->add_service($1);
+        if (! g_program->is_unique_typename($1)) {
+          yyerror("Type \"%s\" is already defined.", $1->get_name().c_str());
+          exit(1);
+        }
       }
       $$ = $1;
     }