View Issue Details

IDProjectCategoryView StatusLast Update
0003600JEDI VCL00 JVCL Componentspublic2006-04-21 03:05
Reporterivan_raAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.10 
Target VersionFixed in Version3.30 
Summary0003600: JvInterpreter does not recognizes unassigned values (workaround)
DescriptionJvInterpreter raises on any of this scripts:

procedure testEmpty1;
var temp:string;
begin
  ShowMessage(temp);
end;

procedure testEmpty1;
var temp1,temp2:variant;
begin
  temp1:=temp2;
end;

procedure TestExcel;
var Sheet,aValue:variant;
begin
  Sheet:=CreateOleObject('Excel.Sheet');
  aValue:=Sheet.Application.range('a1').Value; // here
  showmessage(aValue);
end;
Additional Informationthis repeats every time when expression returns unassigned value. in this case JvInterpreter assumes what there is no code in this place.
The cause of problem is incomplete TJvInterpreterExpression.Expression1 function. This is patch fixing this problem
TagsNo tags attached.

Activities

2006-03-21 01:18

 

JvInterpreter.pas.patch (1,185 bytes)
Index: run/JvInterpreter.pas
===================================================================
RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvInterpreter.pas,v
retrieving revision 1.72
diff -u -r1.72 JvInterpreter.pas
--- run/JvInterpreter.pas	20 Mar 2006 11:59:57 -0000	1.72
+++ run/JvInterpreter.pas	21 Mar 2006 07:28:47 -0000
@@ -5381,7 +5381,7 @@
             NextToken;
           end;
         ttRB:
-          if TVarData(Result).VType = varEmpty then
+          if (TVarData(Result).VType = varEmpty) and (FprevTTyp<>ttIdentifier) then
             ErrorExpected(LoadStr2(irExpression))
           else
             Exit;
@@ -5394,12 +5394,12 @@
             NextToken;
           end;
         ttRS:
-          if TVarData(Result).VType = varEmpty then
+          if (TVarData(Result).VType = varEmpty) and (FprevTTyp<>ttIdentifier) then
             ErrorExpected(LoadStr2(irExpression))
           else
             Exit;
       else
-        if TVarData(Result).VType = varEmpty then
+        if (TVarData(Result).VType = varEmpty) and (FprevTTyp<>ttIdentifier) then
           ErrorExpected(LoadStr2(irExpression))
         else
           Exit;
JvInterpreter.pas.patch (1,185 bytes)

2006-03-22 09:22

 

JvInterpreter.pas.patch1 (1,488 bytes)

ivan_ra

2006-03-22 09:23

developer   ~0008716

Last edited: 2006-03-22 11:37

Sorry, the patch was incomplete. Use JvInterpreter.pas.patch1
It can handle functions returning unassigned value too

ivan_ra

2006-04-05 01:43

developer   ~0008951

What about this patch? its very simple
JvInterpreter.pas.patch handles unassigned variables, properties and functions without arguments.
JvInterpreter.pas.patch1 also handles same expressions:

aValue:=SomeFunctionReturningUnassignedValue(x1,x2,x3);

2006-04-20 01:38

 

JvInterpreter.pas.svn.patch (1,296 bytes)
Index: JvInterpreter.pas
===================================================================
--- JvInterpreter.pas	(revision 10535)
+++ JvInterpreter.pas	(working copy)
@@ -5211,10 +5211,12 @@
   function Expression(const OpTyp: TTokenKind): Variant;
   var
     Tmp: Variant;
+    aPrevTTyp:integer;
   begin
     Result := Unassigned;
     if OpTyp <> ttUnknown then
       NextToken;
+    aPrevTTyp:=TTyp;
     while True do
     begin
       case TTyp of
@@ -5390,7 +5392,7 @@
             NextToken;
           end;
         ttRB:
-          if TVarData(Result).VType = varEmpty then
+          if (TVarData(Result).VType = varEmpty) and (aPrevTTyp<>ttIdentifier) then
             ErrorExpected(LoadStr2(irExpression))
           else
             Exit;
@@ -5403,12 +5405,12 @@
             NextToken;
           end;
         ttRS:
-          if TVarData(Result).VType = varEmpty then
+          if (TVarData(Result).VType = varEmpty) and (aPrevTTyp<>ttIdentifier) then
             ErrorExpected(LoadStr2(irExpression))
           else
             Exit;
       else
-        if TVarData(Result).VType = varEmpty then
+        if (TVarData(Result).VType = varEmpty) and (aPrevTTyp<>ttIdentifier) then
           ErrorExpected(LoadStr2(irExpression))
         else
           Exit;

obones

2006-04-21 03:05

administrator   ~0009163

This is now in SVN. Next time, please respect the style guide for the JVCL, it is VERY annoying to have to change code before inclusion.
And a bit of background info: When an issue is set to "Acknowledged", it means that we have seen it, that we understand it, but we don't have the time to look at it right now. There is no point adding a new note to the issue unless you provide new files or new information.

Issue History

Date Modified Username Field Change
2006-03-21 01:16 ivan_ra New Issue
2006-03-21 01:18 ivan_ra File Added: JvInterpreter.pas.patch
2006-03-22 09:22 ivan_ra File Added: JvInterpreter.pas.patch1
2006-03-22 09:23 ivan_ra Note Added: 0008716
2006-03-22 11:37 ivan_ra Note Edited: 0008716
2006-04-05 01:43 ivan_ra Note Added: 0008951
2006-04-07 04:05 obones Status new => acknowledged
2006-04-20 01:38 ivan_ra File Added: JvInterpreter.pas.svn.patch
2006-04-21 03:05 obones Status acknowledged => resolved
2006-04-21 03:05 obones Fixed in Version => Daily / SVN
2006-04-21 03:05 obones Resolution open => fixed
2006-04-21 03:05 obones Assigned To => obones
2006-04-21 03:05 obones Note Added: 0009163