The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,343 other followers

Archive for the ‘Delphi 10.2 Tokyo (Godzilla)’ Category

Delphi 10.2 Tokyo introduced a “with” warning: for most “with” statements, W1048 is raised ([RSP-17326] with statements generate W1048 unsafe typecast warning – Embarcadero Technologies)

Posted by jpluimers on 2021/05/05

A cool feature introduced in Delphi 10.2 Tokyo: often [RSP-17326] with statements generate W1048 unsafe typecast warning – Embarcadero Technologies.

Only 2 upvotes, so I assume the “anti with camp” people are finally winning (:

Notes:

Quoted from the bug-report (as they cannot be archived in the wayback machine)

  1. RAD Studio
  2. RSP-17326

with statements generate W1048 unsafe typecast warning

Details

  • Type:Bug Bug
  • Status:Reported Reported
  • Priority:Major Major
  • Resolution:Unresolved
  • Affects Version/s:10.2 Tokyo
  • Fix Version/s:None
  • Component/s:Delphi Compiler
  • Labels: None
  • Build No: 25.0.25948.9960
  • Platform: All
  • Language Version: English
  • Edition: Enterprise
  • InternalID: RS-82298
  • InternalStatus: Validation

Description

All with statements generate this warning. I am on board with the theory that all with statements are inherently somewhat unsafe, but with 1.5 million lines of legacy code (and over 500 new warnings), I would significantly prefer to have a separate warning for with statements.
As it happens I would like to go through and do this work, especially if we can have refactoring to restore non-with code – see RSP-13978. BUT, Godzilla is generating new extra warnings (including unsafe typecasts) in this legacy code and I would prefer to be able to attack these first and attend to with statements later.

Activity

Comments

Jira-Quality Sync Service added a comment – 

Jason Sprenger requested more info in order to validate the issue and commented: Not any code involving “with” statements produces an unsafe typecast warning.

For instance,

program RS82298;

{$APPTYPE CONSOLE}

uses
  System.SysUtils;

procedure Use(var X);
begin<
end;

type
  TMyClass = class
    FValue: Integer;
    property Value: Integer read FValue write FValue;
  end;

procedure RunRS82298;
var
  MyClass: TMyClass;
begin
  MyClass := TMyClass.Create;
  with MyClass do
    begin
      Value := 42;
    end;
  with MyClass do
    WriteLn('MyClass.Value=', MyClass.Value);

  Use(MyClass);
end;

begin
  try
    RunRS82298
  except
    on E: Exception do
      begin
        WriteLn('FAIL - Unexpected Exception');
        WriteLn('  ClassName=', E.ClassName);
        WriteLn('    Message=', E.Message);
      end;
  end;
end.

What sort of source involving “with” statements is generating these warnings for you?

With this information our development team can consider addressing your particular circumstance.

Stuart Seath [X] (Inactive) added a comment – 

Try this (obviously a simple made-up example), and you do need to enable W1048 first in the project options:

program Project18;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

type
  TAnother = class
  private
    FAmbiguous : Boolean;
  public
    property Ambiguous : Boolean read FAmbiguous write FAmbiguous;
  end;

  TFirst = class
  private
    FAnother : TAnother;
  public
    procedure Doit;
  end;

var
  First : TFirst;

{ TFirst }

procedure TFirst.Doit;
begin
  FAnother := TAnother.Create;
  with FAnother do // WARNING
  begin
    Ambiguous := true;
  end;
end;

var
  XAnother : TAnother;

begin
  try
    XAnother := TAnother.Create;
    with XAnother do // NO WARNING HERE
    begin
      Ambiguous := true;
    end;

  except
    on E: Exception do
  Writeln(E.ClassName, ': ', E.Message);
end;
end.

–jeroen

Posted in Delphi, Delphi 10.2 Tokyo (Godzilla), Development, Software Development | 1 Comment »

I’m using Delphi XE 10.2: empty documentation tab means you need to update to either the documentation Hotfix or 10.2.3

Posted by jpluimers on 2020/12/03

If you see the Documentation tab like below you need to either:

The problem is caused by Embarcadero using mixed technologies in the Delphi IDE combined with their lack of testing due to not eating their own dog-food.

Too bad, as the documentation over the last versions has finally increased after a 10+ year steady decline.

Doing one technology right is hard, but having to mix multiple technologies into one product is extremely hard.

Via: [WayBack] I’m using Delphi XE 10.2. Whenever I click on the Documentation tab, I see the following uselessly rendered page. I can’t seem to resize it either. Anyb… – Graeme Geldenhuys – Google+

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi 10.2 Tokyo (Godzilla), Development, Software Development | Leave a Comment »

Interface methods are not assignment compatible with method references or methods of object.

Posted by jpluimers on 2019/04/02

Boy I wish that QC was still up and QualityPortal was publicly indexable as that would have saved me quite a bit of time tracking this down. Luckily I got help from Stefan Glienke (who maintains the awesome Spring4D library based on modern Delphi compiler support) when I mentioned

How good are you with reference to function?
I’ve an odd compiler thing throwing errors when using interfaces but not with classes.

So, for posterity:

Unlike C#, in Delphi interface methods are not compatible with method references or methods of object.

This has many manifestations, which means you can get a variety of compiler errors. I’ve listed the ones I could find below, but presume there are more and if I find more will update this post.

These are the errors you can get:

  • E2010 Incompatible types: ‘T’ and ‘Procedure’
  • E2035 Not enough actual parameters
  • E2250 There is no overloaded version of ‘FirstOrDefault’ that can be called with these arguments

These are the (now defunct, but used to be publicly accessible) QC and QualityPortal (needs sign on) entries (thanks Stefan Glienke and Blaise Thorn for reporting these):

The really frustrating part is that the RSP is marked as “new feature” whereas clearly it isn’t, so it probably never will be fixed.

A workaround for now is to wrap the interface method references with:

  • either anonymous methods (when you have just a few classes to cover, but maybe more than a few methods on the interface)
  • or instance methods on a class (when there are many classes to cover and preferably few methods on the interface)

Examples are in the code below that also shows this works fine and dandy in C#.

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 10.2 Tokyo (Godzilla), Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development, Spring4D | Leave a Comment »

Berlin 10.1.2 Vcl.RibbonConsts removed, so now Vcl.ScreenTips compilation fails – Pascal Today

Posted by jpluimers on 2019/02/12

The Ribbon controls got removed since Delphi 10.1 Berlin, but the dependency in Vcl.ScreenTips remained, so:

After installing the official Delphi Berlin Update 2 I have faced nasty problem. One of my unit was using the Vcl.ScreenTips unit (for TScreenTipsWindow). And when you compile such a project you ge…

Source: Berlin 10.1.2 Vcl.ScreenTips compilation fail – Pascal Today

In the mean time however, it has been moved to GetIt: [WayBack] Ribbon Controls in RAD Studio 10.1 Berlin.

Note that the XE8 introduced [Archive.is] GetIt package manager is under the Tools menu, which is not covered by [Archive.is] IDE Insight – RAD Studio.

Anyway: here you can get it in Delphi 10.1 Berlin (now also in 10.2 Tokyo, where at first it was not available through GetIt):

jeroen

Posted in Delphi, Delphi 10.1 Berlin (BigBen), Delphi 10.2 Tokyo (Godzilla), Development, Software Development | Leave a Comment »

Don’t expect high floating point performance from the Delphi for Linux compiler

Posted by jpluimers on 2018/07/31

Don’t expect high floating point performance of the Delphi for Linux compiler as this thread proves it is not: [WayBack] Based on a recent post here, it looks like the new Linux compiler uses the x87 unit for floating point. Naturally this won’t perform well. If it is true… – David Heffernan – Google+

–jeroen

Posted in Delphi, Delphi 10.2 Tokyo (Godzilla), Development, Software Development | 5 Comments »

 
%d bloggers like this: