Compiler crash using local constant array

Issue #49 resolved
Christian Budde created an issue

The code below results in a compiler crash:

procedure Test; const CColors = [ ['#df0049', '#660671'], ['#ffd200', '#b06c00'] ]; begin ShowMessage(CColors[RandomInt(2)][RandomInt(1)]); end;

with the following stack trace:

dwsVCLGUIFunctions.TShowMessageFunc.DoEvalProc((nil, 0, $22D7470)) dwsMagicExprs.TMagicProcedureExpr.EvalNoResult($22D7470) dwsMagicExprs.TMagicProcedureExpr.EvalAsVariant($22D7470,Nicht zugewiesen) dwsExprs.TProgramExpr.EvalAsScriptDynArray($22D7470,Pointer($698620) as IScriptDynArray) dwsSymbols.TTypeSymbol.IsOfType($22D7470) dwsExprs.TTypedExpr.IsOfType($22D7470) dwsCompiler.TdwsCompiler.ReadSymbol($22C2CA0,False,nil) dwsCompiler.TdwsCompiler.ReadConstName($2A1D230,False) dwsCompiler.TdwsCompiler.ReadName(False,$22D7470) dwsCompiler.TdwsCompiler.ReadTerm(False,$22D7470) dwsCompiler.TdwsCompiler.ReadExprMult($22D7470,nil) dwsCompiler.TdwsCompiler.ReadExprAdd($22D7470,nil) dwsCompiler.TdwsCompiler.ReadExpr($22D7470) dwsCompiler.TdwsCompiler.ReadArguments((dwsExprs.TFuncExprBase.AddArg,$2339CD8),ttBLEFT,ttBRIGHT,(),(dwsMagicExprs.TMagicFuncExpr.ExpectedArg,$2339CD8))

If I change the 'const' to a 'var' everything seems to be working fine.

Comments (2)

  1. Log in to comment