[ 
https://issues.apache.org/jira/browse/THRIFT-2916?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Phongphan Phuttha updated THRIFT-2916:
--------------------------------------
    Comment: was deleted

(was: Looks like the problem might be from insufficient code generation for 
{{set}}.

In {{DebugProtoTest.thrift}}, we have
{noformat}
struct Empty {
}

struct CompactProtoTestStruct {
  19: list<Empty>  struct_list;
}
{noformat}

Which generates
{noformat}
struct Empty {
  mixin TStructHelpers!();
}

struct CompactProtoTestStruct {
  HashSet!(Empty) struct_set;
}
{noformat}

Looks like {{struct}} doesn't provide the default {{size_t toHash() const @safe 
pure nothrow;}} method, which is required by 
[HashSet|http://dlang.org/hash-map.html].

Here's a proof of concept which made {{make check}} passed, but it might be not 
sufficient.
{noformat}
diff --git a/compiler/cpp/src/generate/t_d_generator.cc 
b/compiler/cpp/src/generate/t_d_generator.cc
index ca76485..1ab3bdf 100644
--- a/compiler/cpp/src/generate/t_d_generator.cc
+++ b/compiler/cpp/src/generate/t_d_generator.cc
@@ -459,6 +459,15 @@ private:
 
     out << ");" << endl;
 
+    if (!is_exception) {
+      out << endl;
+      indent(out) << "size_t toHash() const @safe pure nothrow {" << endl;
+      indent_up();
+      indent(out) << "return cast(size_t)&this;" << endl;
+      indent_down();
+      indent(out) << "}" << endl;
+    }
+
     indent_down();
     indent(out) << "}" << endl << endl;
   }
{noformat}

Not sure if we required to generate {{toHash}} from all members. Or maybe just 
convert {{struct}} to {{class}}?)

> make check fails for D language
> -------------------------------
>
>                 Key: THRIFT-2916
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2916
>             Project: Thrift
>          Issue Type: Bug
>          Components: D - Library
>         Environment: openSUSE 13.2
> DMD32 D Compiler v2.066.1
>            Reporter: Jens Geyer
>
> make check fails for D language with multiple error messages:
> {code}
> dmd   -w -wi -O -release -inline -I../../../lib/d/src -Igen-d 
> ../../../lib/d/libthriftd.a -ofserialization_benchmark 
> serialization_benchmark.d gen-d/DebugProtoTest_types.d
> ../../../lib/d/src/thrift/util/hashset.d(120): Error: AA key type Empty 
> should have 'size_t toHash() const nothrow @safe' if opEquals defined
> gen-d/DebugProtoTest_types.d(218): Error: template instance 
> thrift.util.hashset.HashSet!(Empty) error instantiating
> ../../../lib/d/src/thrift/codegen/base.d-mixin-544(736): Error: undefined 
> identifier meta
> ../../../lib/d/src/thrift/codegen/base.d-mixin-544(736): Error: static assert 
>  __error
> ../../../lib/d/src/thrift/codegen/base.d(371):        instantiated from here: 
> TIsSetFlags!(CompactProtoTestStruct, [TFieldMeta("a_byte", cast(short)1, 
> cast(TReq)1, null), TFieldMeta("a_i16", cast(short)2, cast(TReq)1, null), 
> TFieldMeta("a_i32", cast(short)3, cast(TReq)1, null), TFieldMeta("a_i64", 
> cast(short)4, cast(TReq)1, null), TFieldMeta("a_double", cast(short)5, 
> cast(TReq)1, null), TFieldMeta("a_string", cast(short)6, cast(TReq)1, null), 
> TFieldMeta("a_binary", cast(short)7, cast(TReq)1, null), 
> TFieldMeta("true_field", cast(short)8, cast(TReq)1, null), 
> TFieldMeta("false_field", cast(short)9, cast(TReq)1, null), 
> TFieldMeta("empty_struct_field", cast(short)10, cast(TReq)1, null), 
> TFieldMeta("byte_list", cast(short)11, cast(TReq)1, null), 
> TFieldMeta("i16_list", cast(short)12, cast(TReq)1, null), 
> TFieldMeta("i32_list", cast(short)13, cast(TReq)1, null), 
> TFieldMeta("i64_list", cast(short)14, cast(TReq)1, null), 
> TFieldMeta("double_list", cast(short)15, cast(TReq)1, null), 
> TFieldMeta("string_list", cast(short)16, cast(TReq)1, null), 
> TFieldMeta("binary_list", cast(short)17, cast(TReq)1, null), 
> TFieldMeta("boolean_list", cast(short)18, cast(TReq)1, null), 
> TFieldMeta("struct_list", cast(short)19, cast(TReq)1, null), 
> TFieldMeta("byte_set", cast(short)20, cast(TReq)1, null), 
> TFieldMeta("i16_set", cast(short)21, cast(TReq)1, null), 
> TFieldMeta("i32_set", cast(short)22, cast(TReq)1, null), 
> TFieldMeta("i64_set", cast(short)23, cast(TReq)1, null), 
> TFieldMeta("double_set", cast(short)24, cast(TReq)1, null), 
> TFieldMeta("string_set", cast(short)25, cast(TReq)1, null), 
> TFieldMeta("binary_set", cast(short)26, cast(TReq)1, null), 
> TFieldMeta("boolean_set", cast(short)27, cast(TReq)1, null), 
> TFieldMeta("struct_set", cast(short)28, cast(TReq)1, null), 
> TFieldMeta("byte_byte_map", cast(short)29, cast(TReq)1, null), 
> TFieldMeta("i16_byte_map", cast(short)30, cast(TReq)1, null), 
> TFieldMeta("i32_byte_map", cast(short)31, cast(TReq)1, null), 
> TFieldMeta("i64_byte_map", cast(short)32, cast(TReq)1, null), 
> TFieldMeta("double_byte_map", cast(short)33, cast(TReq)1, null), 
> TFieldMeta("string_byte_map", cast(short)34, cast(TReq)1, null), 
> TFieldMeta("binary_byte_map", cast(short)35, cast(TReq)1, null), 
> TFieldMeta("boolean_byte_map", cast(short)36, cast(TReq)1, null), 
> TFieldMeta("byte_i16_map", cast(short)37, cast(TReq)1, null), 
> TFieldMeta("byte_i32_map", cast(short)38, cast(TReq)1, null), 
> TFieldMeta("byte_i64_map", cast(short)39, cast(TReq)1, null), 
> TFieldMeta("byte_double_map", cast(short)40, cast(TReq)1, null), 
> TFieldMeta("byte_string_map", cast(short)41, cast(TReq)1, null), 
> TFieldMeta("byte_binary_map", cast(short)42, cast(TReq)1, null), 
> TFieldMeta("byte_boolean_map", cast(short)43, cast(TReq)1, null), 
> TFieldMeta("list_byte_map", cast(short)44, cast(TReq)1, null), 
> TFieldMeta("set_byte_map", cast(short)45, cast(TReq)1, null), 
> TFieldMeta("map_byte_map", cast(short)46, cast(TReq)1, null), 
> TFieldMeta("byte_map_map", cast(short)47, cast(TReq)1, null), 
> TFieldMeta("byte_set_map", cast(short)48, cast(TReq)1, null), 
> TFieldMeta("byte_list_map", cast(short)49, cast(TReq)1, null)])
> Makefile:727: recipe for target 'serialization_benchmark' failed
> make[2]: *** [serialization_benchmark] Error 1
> make[2]: Leaving directory '/home/jens/Arbeitsfläche/Thrift/haxe/lib/d/test'
> Makefile:594: recipe for target 'check-am' failed
> make[1]: *** [check-am] Error 2
> make[1]: Leaving directory '/home/jens/Arbeitsfläche/Thrift/haxe/lib/d/test'
> Makefile:835: recipe for target 'check-recursive' failed
> make: *** [check-recursive] Error 1
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to