THRIFT-5588 Remove slist/senum from IDL
Patch: Jens Geyer

This closes #2615
diff --git a/compiler/cpp/src/thrift/common.cc b/compiler/cpp/src/thrift/common.cc
index fb1832d..6dcd855 100644
--- a/compiler/cpp/src/thrift/common.cc
+++ b/compiler/cpp/src/thrift/common.cc
@@ -23,7 +23,6 @@
 t_type* g_type_void;
 t_type* g_type_string;
 t_type* g_type_binary;
-t_type* g_type_slist;
 t_type* g_type_bool;
 t_type* g_type_i8;
 t_type* g_type_i16;
@@ -36,8 +35,6 @@
   g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);
   g_type_binary = new t_base_type("string", t_base_type::TYPE_STRING);
   ((t_base_type*)g_type_binary)->set_binary(true);
-  g_type_slist = new t_base_type("string", t_base_type::TYPE_STRING);
-  ((t_base_type*)g_type_slist)->set_string_list(true);
   g_type_bool = new t_base_type("bool", t_base_type::TYPE_BOOL);
   g_type_i8 = new t_base_type("i8", t_base_type::TYPE_I8);
   g_type_i16 = new t_base_type("i16", t_base_type::TYPE_I16);
diff --git a/compiler/cpp/src/thrift/common.h b/compiler/cpp/src/thrift/common.h
index 6948846..06392cd 100644
--- a/compiler/cpp/src/thrift/common.h
+++ b/compiler/cpp/src/thrift/common.h
@@ -29,7 +29,6 @@
 extern t_type* g_type_void;
 extern t_type* g_type_string;
 extern t_type* g_type_binary;
-extern t_type* g_type_slist;
 extern t_type* g_type_bool;
 extern t_type* g_type_i8;
 extern t_type* g_type_i16;
diff --git a/compiler/cpp/src/thrift/generate/t_perl_generator.cc b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
index 2e687dd..68bd57f 100644
--- a/compiler/cpp/src/thrift/generate/t_perl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
@@ -998,15 +998,17 @@
     const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
     vector<t_field*>::const_iterator a_iter;
     for (a_iter = args.begin(); a_iter != args.end(); ++a_iter) {
-      t_type* atype = get_true_type((*a_iter)->get_type());
+      //t_type* atype = get_true_type((*a_iter)->get_type());
       string req = "$request->{'" + (*a_iter)->get_name() + "'}";
       f_service_ << indent() << "my $" << (*a_iter)->get_name() << " = (" << req << ") ? " << req
                  << " : undef;" << endl;
-      if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
+      /* slist no longer supported
+	  if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
         f_service_ << indent() << "my @" << (*a_iter)->get_name() << " = split(/,/, $"
                    << (*a_iter)->get_name() << ");" << endl << indent() << "$"
                    << (*a_iter)->get_name() << " = \\@" << (*a_iter)->get_name() << endl;
       }
+	  */
     }
     f_service_ << indent() << "return $self->{impl}->" << (*f_iter)->get_name() << "("
                << argument_list((*f_iter)->get_arglist()) << ");" << endl;
diff --git a/compiler/cpp/src/thrift/generate/t_php_generator.cc b/compiler/cpp/src/thrift/generate/t_php_generator.cc
index 96d5fbe..39968a6 100644
--- a/compiler/cpp/src/thrift/generate/t_php_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_php_generator.cc
@@ -1785,10 +1785,12 @@
         f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = isset(" << req << ") ? "
                    << cast << req << " : null;" << endl;
       }
+      /* slist no longer supported
       if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
         f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = explode(',', $"
                        << (*a_iter)->get_name() << ");" << endl;
-      } else if (atype->is_map() || atype->is_list()) {
+      } else */
+      if (atype->is_map() || atype->is_list()) {
         f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = json_decode($"
                        << (*a_iter)->get_name() << ", true);" << endl;
       } else if (atype->is_set()) {
diff --git a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
index d7fb6cf..a10f059 100644
--- a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
@@ -132,21 +132,8 @@
 void t_xsd_generator::generate_typedef(t_typedef* ttypedef) {
   indent(s_xsd_types_) << "<xsd:simpleType name=\"" << ttypedef->get_name() << "\">" << endl;
   indent_up();
-  if (ttypedef->get_type()->is_string() && ((t_base_type*)ttypedef->get_type())->is_string_enum()) {
-    indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\">"
-                         << endl;
-    indent_up();
-    const vector<string>& values = ((t_base_type*)ttypedef->get_type())->get_string_enum_vals();
-    vector<string>::const_iterator v_iter;
-    for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) {
-      indent(s_xsd_types_) << "<xsd:enumeration value=\"" << (*v_iter) << "\" />" << endl;
-    }
-    indent_down();
-    indent(s_xsd_types_) << "</xsd:restriction>" << endl;
-  } else {
-    indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\" />"
-                         << endl;
-  }
+  indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\" />"
+                       << endl;
   indent_down();
   indent(s_xsd_types_) << "</xsd:simpleType>" << endl << endl;
 }
diff --git a/compiler/cpp/src/thrift/parse/t_base_type.h b/compiler/cpp/src/thrift/parse/t_base_type.h
index ca2b0f6..5676f04 100644
--- a/compiler/cpp/src/thrift/parse/t_base_type.h
+++ b/compiler/cpp/src/thrift/parse/t_base_type.h
@@ -45,7 +45,7 @@
   };
 
   t_base_type(std::string name, t_base base)
-    : t_type(name), base_(base), string_list_(false), binary_(false), string_enum_(false) {}
+    : t_type(name), base_(base), binary_(false) {}
 
   t_base get_base() const { return base_; }
 
@@ -55,22 +55,10 @@
 
   bool is_bool() const override { return base_ == TYPE_BOOL; }
 
-  void set_string_list(bool val) { string_list_ = val; }
-
-  bool is_string_list() const { return string_list_ && (base_ == TYPE_STRING); }
-
   void set_binary(bool val) { binary_ = val; }
 
   bool is_binary() const override { return binary_ && (base_ == TYPE_STRING); }
 
-  void set_string_enum(bool val) { string_enum_ = val; }
-
-  bool is_string_enum() const { return string_enum_ && base_ == TYPE_STRING; }
-
-  void add_string_enum_val(std::string val) { string_enum_vals_.push_back(val); }
-
-  const std::vector<std::string>& get_string_enum_vals() const { return string_enum_vals_; }
-
   bool is_base_type() const override { return true; }
 
   static std::string t_base_name(t_base tbase) {
@@ -108,10 +96,7 @@
 private:
   t_base base_;
 
-  bool string_list_;
   bool binary_;
-  bool string_enum_;
-  std::vector<std::string> string_enum_vals_;
 };
 
 #endif
diff --git a/compiler/cpp/src/thrift/thriftl.ll b/compiler/cpp/src/thrift/thriftl.ll
index 3773516..810a983 100644
--- a/compiler/cpp/src/thrift/thriftl.ll
+++ b/compiler/cpp/src/thrift/thriftl.ll
@@ -86,6 +86,12 @@
   exit(1);
 }
 
+void error_no_longer_supported(char* text, char* replace_with) {
+  yyerror("\"%s\" is no longer supported, use \"%s\" instead. Line %d\n", text, replace_with, yylineno);
+  exit(1);
+}
+
+
 %}
 
 /**
@@ -234,12 +240,10 @@
 "string"             { return tok_string;               }
 "binary"             { return tok_binary;               }
 "slist" {
-  pwarning(0, "\"slist\" is deprecated and will be removed in a future compiler version.  This type should be replaced with \"string\".\n");
-  return tok_slist;
+  error_no_longer_supported("slist","string");
 }
 "senum" {
-  pwarning(0, "\"senum\" is deprecated and will be removed in a future compiler version.  This type should be replaced with \"string\".\n");
-  return tok_senum;
+  error_no_longer_supported("senum","string");
 }
 "map"                { return tok_map;                  }
 "list"               { return tok_list;                 }
diff --git a/compiler/cpp/src/thrift/thrifty.yy b/compiler/cpp/src/thrift/thrifty.yy
index dc6838a..a062a0e 100644
--- a/compiler/cpp/src/thrift/thrifty.yy
+++ b/compiler/cpp/src/thrift/thrifty.yy
@@ -134,8 +134,6 @@
 %token tok_bool
 %token tok_string
 %token tok_binary
-%token tok_slist
-%token tok_senum
 %token tok_i8
 %token tok_i16
 %token tok_i32
@@ -205,10 +203,6 @@
 %type<tenumv>    EnumDef
 %type<tenumv>    EnumValue
 
-%type<ttypedef>  Senum
-%type<tbase>     SenumDefList
-%type<id>        SenumDef
-
 %type<tconst>    Const
 %type<tconstv>   ConstValue
 %type<tconstv>   ConstList
@@ -404,13 +398,6 @@
         g_program->add_enum($1);
       }
     }
-| Senum
-    {
-      pdebug("TypeDefinition -> Senum");
-      if (g_parse_mode == PROGRAM) {
-        g_program->add_typedef($1);
-      }
-    }
 | Struct
     {
       pdebug("TypeDefinition -> Struct");
@@ -530,39 +517,6 @@
       $$ = new t_enum_value($1, y_enum_val);
     }
 
-Senum:
-  tok_senum tok_identifier '{' SenumDefList '}' TypeAnnotations
-    {
-      pdebug("Senum -> tok_senum tok_identifier { SenumDefList }");
-      validate_simple_identifier( $2);
-      $$ = new t_typedef(g_program, $4, $2);
-      if ($6 != nullptr) {
-        $$->annotations_ = $6->annotations_;
-        delete $6;
-      }
-    }
-
-SenumDefList:
-  SenumDefList SenumDef
-    {
-      pdebug("SenumDefList -> SenumDefList SenumDef");
-      $$ = $1;
-      $$->add_string_enum_val($2);
-    }
-|
-    {
-      pdebug("SenumDefList -> ");
-      $$ = new t_base_type("string", t_base_type::TYPE_STRING);
-      $$->set_string_enum(true);
-    }
-
-SenumDef:
-  tok_literal CommaOrSemicolonOptional
-    {
-      pdebug("SenumDef -> tok_literal");
-      $$ = $1;
-    }
-
 Const:
   tok_const FieldType tok_identifier '=' ConstValue CommaOrSemicolonOptional
     {
@@ -1048,11 +1002,6 @@
       pdebug("BaseType -> tok_binary");
       $$ = g_type_binary;
     }
-| tok_slist
-    {
-      pdebug("BaseType -> tok_slist");
-      $$ = g_type_slist;
-    }
 | tok_bool
     {
       pdebug("BaseType -> tok_bool");
diff --git a/test/AnnotationTest.thrift b/test/AnnotationTest.thrift
index 9258322..8818e74 100644
--- a/test/AnnotationTest.thrift
+++ b/test/AnnotationTest.thrift
@@ -49,14 +49,6 @@
   SATURDAY ( weekend = "yes" )
 } (foo.bar="baz")
 
-/* Note that annotations on senum values are not supported. */
-senum seasons {
-  "Spring",
-  "Summer",
-  "Fall",
-  "Winter"
-} ( foo = "bar" )
-
 struct ostr_default {
   1: i32 bar;
 }
diff --git a/test/SmallTest.thrift b/test/SmallTest.thrift
index d0821c7..955cdc9 100644
--- a/test/SmallTest.thrift
+++ b/test/SmallTest.thrift
@@ -24,12 +24,6 @@
   1: i32 val = 325;
 }
 
-senum Thinger {
-  "ASDFKJ",
-  "r32)*F#@",
-  "ASDFLJASDF"
-}
-
 struct BoolPasser {
   1: bool value = 1
 }
@@ -52,6 +46,10 @@
   3: map<i32, map<i32,i32>> complexer,
 }
 
+struct Thinger {
+  1: i32 dummy
+}
+
 service SmallService {
   Thinger testThinger(1:Thinger bootz),
   Hello testMe(1:i32 hello=64, 2: Hello wonk) throws (1: Goodbye g),