WST: Illegal type conversion: "new_record" to "Pointer" in generated binder lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- tom.tom · 2013-05-09 14:09 hi, I'm working on my SOAP web service and have come across following issue: when in an interface the simple record type is defined as follows: Code: [Select]  new_record = record     test : string;   end;  and it is used as an input parameter to some web method - i.e. Code: [Select]    procedure new_proc(       const  AValue : new_record     ); then in the binder, the following autogenerated code works fine: Code: [Select]procedure TSampleService_ServiceBinder.new_procHandler(AFormatter : IFormatterResponse; AContext : ICallContext); var   (...)   AValue : new_record; begin   callCtx := AContext;   Fillchar(AValue,SizeOf(new_record),#0);     locStrPrmName := 'AValue';  AFormatter.Get(TypeInfo(new_record),locStrPrmName,AValue);   if ( PTypeInfo(TypeInfo(new_record))^.Kind = tkClass ) and Assigned(Pointer(AValue)) then     callCtx.AddObjectToFree(TObject(AValue)); but if I change the definition of the record to: Code: [Select]  new_record = record     test : string;     test2 : string;   end;    then the compilation fails in a binder on line: Code: [Select]  if ( PTypeInfo(TypeInfo(new_record))^.Kind = tkClass ) and Assigned(Pointer(AValue)) then with message: Code: [Select]  Error: Illegal type conversion: "new_record" to "Pointer" I'm not an expert in OP internals and how the record vs. class structures are handled, so could anybody please explain what is happening? Is it because if inside the record there is only one field the record is treated as if it was directly that field (string in this case) which can be casted to Pointer but if there are more fields it cannot be casted since it is not a pointer...? Cheers, Tom ---------------------------------------------------------------------- Dibo · 2013-05-09 15:10 Last time when I worked on SOAP and WST was a 3 years ago, but what I remember you  should not change autogenerated types manually. However if you must, then you need change it everywhere (especially in wst file definition). I'm pretty sure that in some other file generated by WST exists old definition of new_record ---------------------------------------------------------------------- User137 · 2013-05-09 18:45 If it's put down to this piece: Code: [Select]var AValue : new_record; ... if Assigned(Pointer(AValue)) then1) AValue will never be nil because it's variable. ( 2) i think it should be Assigned(@AValue), if you were to write it like that. ) 3) You cannot typecast a record into generic class object with TObject(AValue). ---------------------------------------------------------------------- taazz · 2013-05-10 06:09 The code shown here is base on the short circuit Boolean evaluation, this means that if the first part of the expression is false the second part should not be evaluated. In your case if FPC supports short circuit evaluation it should not make any difference. By the error I assume that it does not. ---------------------------------------------------------------------- tom.tom · 2013-05-10 12:45 @Dibo: it does not matter if I manually modify the record or add a new property using WST wizard - the result is the same @User137, @taazz: this fails on COMPILATION not at runtime So, this means there is apparently a bug in WST autogenerated code as it also looks bizzare to me that the record type is being checked and casted like an object. Now I'm wondering how come that such an obvious issie has not been fixed yet... or maybe I'm doing something wrong... or maybe the record types should not be used as input params in WST?