This forum is temporaily read-only. All existing discussions remain available for reference. For new questions, bug reports or support requests, please contact us at mail@lmdsupport.com.

TLMDScriptControl.Prepare() hangs indefinitely for a specific syntax pattern

Hi,

we’ve encountered a reproducible issue with TLMDScriptControl.Prepare() that appears to be a parser/compiler problem in Pascal-Script.

Prepare() hangs indefinitely for a specific syntax pattern.

Example Script:
var
  i, x;
begin
  x := 'a';
  for i := 0 to 10 do
  begin    
    if (x = 'a') or (x = 'x') then
      ShowMessage('a')
    else
      ShowMessage('b');
  end;
end;

As far as we observed, the issue only occurs with this combination:
  • for loop
  • if..then..else
  • or-condition
  • parenthesized sub-expressions
Variations that work:
  • Removing parentheses around the OR operands (if x = 'a' or x = 'x' then)
  • Removing the else branch
  • Removing the for loop
  • Splitting the condition:
     if x = 'a' then
       ...
     else if x = 'x' then
       ...

We encountered that Problem in LMD ScriptPack 2022.10 and 2025.4.
Is this a known issue in the Pascal-Script parser/compiler?

Comments

  • Confirmed. Need some time to resort.
  • Hi, fixed. If you want a quick fix, please modify the following lines in TLMDByteCode.CalcStackSize method:

          icPopJmpIfEqual,
          icPopJmpIfNotEqual:
          begin
            _AddChunk(TLMDLabel(cur^.Data), curLength - 2);
            Dec(curLength, 2); // <----- here
          end;

  • Thank you for the very quick resolution.
Sign In or Register to comment.