HuubGitHub / dwscript

Automatically exported from code.google.com/p/dwscript
1 stars 0 forks source link

Object array access in external unit causes compile error #424

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a TdwsUnit and attach it to the compiler.  Declare a class "TMyObject"
2. Declare an array "MyObjects", whose base type is TMyObject
3. Try to compile a script containing the line "myObjects[0] := nil;"

This will raise an invalid typecast error in TdwsCompiler.ReadSymbol, at the 
line:

dataExpr:=(Result as TDataExpr);

Result, at this point, is an object of class TTypeReferenceExpr, which is 
almost certainly incorrect.

Original issue reported on code.google.com by masonwhe...@gmail.com on 21 Jun 2013 at 10:17

GoogleCodeExporter commented 8 years ago
I've added a ArrayOfObjects test with those steps, but it doesn't reproduce the 
issue... could you tweak the test so it will fail and trigger the issue?

Original comment by zar...@gmail.com on 25 Jun 2013 at 6:28

GoogleCodeExporter commented 8 years ago
The error can be triggered by removing the variable "a" in the test script, and 
trying to treat the declared array type symbol from the unit as if it were a 
variable:

TDynObjects[0] := nil;

Original comment by masonwhe...@gmail.com on 25 Jun 2013 at 1:53