Bug when idispatch is enabled record properties will not work in class

To reproduce the bug you have to import this unit:

unit testClass;

interface

uses Classes;

type

TEvResultType = (restInt, restDouble, restString, restBool, restError);
TEvResult = record
case Kind : TEvResultType of
restInt : (intResult : longint);
restDouble : (dblResult : double);
restString : (strResult : string[255]);
restBool : (booResult : boolean);
end;

TKomponenta = class(TComponent)
private
fValue: TEvResult;
published
property Value : TEvResult read fValue;
end;

implementation

end.

The following will fail x:=lkomp.value.dblResult; (where x is real) with unknown identifier.

The following will still work:

var lVar: TEvResult;

begin
lVar:=lkomp.value;
x:=lVar.dblResult;
end;

To make the first case to compile you have to add {$DEFINE PS_NOIDISPATCH} to the pascalscript.inc.

Hello,
You wrote:

To reproduce the bug you have to import this unit:

What do you mean under ‘import’? Do you mean import via ‘unit-importing\imp.dpr’ project?
Can describe this situation more detail?

Yes I meant with that utility. The call stack is:

PascalScript_Core_D11.uPSCompiler.GetIdentifier(0)
PascalScript_Core_D11.uPSCompiler.ReadFactor
PascalScript_Core_D11.uPSCompiler.ReadTerm
PascalScript_Core_D11.uPSCompiler.ReadSimpleExpression
PascalScript_Core_D11.uPSCompiler.ReadExpression
PascalScript_Core_D11.uPSCompiler.calc(???)
PascalScript_Core_D11.uPSCompiler.ProcessIdentifier
PascalScript_Core_D11.uPSCompiler.TPSPascalCompiler.ProcessSub($BC7A770)
PascalScript_Core_D11.uPSCompiler.TPSPascalCompiler.ProcessFunction(False,$BCBD5D0)
PascalScript_Core_D11.uPSCompiler.TPSPascalCompiler.Compile(???)
PascalScript_Core_D11.uPSComponent.TPSScript.Compile
dizajner.script_runner.TScript_runner.CompileScript($84ADA00,$4F00B70,$70D7D40,$70FF8B0,True)

The problem is with:

{$IFNDEF PS_NOIDISPATCH}if Result <> nil then CheckIntf(Result, vt, vno, False);{$ENDIF}

Before this line lkomp.value is successfully parsed and the type of the expression is ok. However for some reason CheckIntF will return result to nil and the expression will fail with ecUnknownIdentifier error.

I guess I how found the error in the CheckIntf:

if (FType.BaseType <> btInterface) and (Ftype.BaseType <> BtVariant) and (FType.BaseType = btNotificationVariant) then Exit;

My guess is that instead of FType.BaseType = btNotificationVariant it should be:
FType.BaseType <> btNotificationVariant.

Hello,
Thanks, the issue was logged as #35