JEDI error but unit compiles?? lazarus / 21-General ---------------------------------------------------------------------- bobonwhidbey · 2024-03-27 17:54 I didn't know this was possible. Program compiles and runs but I can't format it with JEDI. Anyone have an idea why? ---------------------------------------------------------------------- bytebites · 2024-03-27 18:03 Programs have features and bugs. Which code fails? ---------------------------------------------------------------------- bobonwhidbey · 2024-03-27 18:21 the code doesn't fail. The ability to format the PAS file fails. ---------------------------------------------------------------------- bytebites · 2024-03-27 18:25 What code is unable to be formatted? ---------------------------------------------------------------------- bobonwhidbey · 2024-03-27 19:48 How can I discover that?  Lots of trial and error by commenting out many lines?  Is there a better way - the pas file is 2,000 lines long. ---------------------------------------------------------------------- Thaddy · 2024-03-27 20:41 well, fix jedi..... if you want to  use it. ---------------------------------------------------------------------- bytebites · 2024-03-27 20:56 Error message appears in the compiler messages window. ---------------------------------------------------------------------- bobonwhidbey · 2024-03-27 23:00 I narrowed the problem down to (* appearing in the code where it's not the start of a comment.  In particular, I had several places with a SQL select statement like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Q.SQL.Text := 'SELECT *, Count(*) AS KT FROM MyTable WHERE  .....'; I couldn't figure out how to fix JEDI ---------------------------------------------------------------------- DomingoGP · 2024-03-28 07:28 I can't reproduce it, could you attach or send me a PM with the failed unit (or a stripped down version of it that gives the error when formatting). ---------------------------------------------------------------------- Roland57 · 2024-03-28 10:50 I would like to see the file too. Meanwhile, if SQL commands are really the issue, you could try to surround them like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {(*}Q.SQL.Text := 'SELECT *, Count(*) AS KT FROM MyTable WHERE  .....';{*)} ---------------------------------------------------------------------- bobonwhidbey · 2024-03-28 16:03 It took me some time to whittle down a large unit to find the problem. You can create a new project with only this little FormShow procedure Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormShow(Sender: TObject);const  TestSET: set of tWindowState = [wsNormal..wsMinimized,wsFullScreen];begin  ShowMessage('Test');end; Of course this compiles and runs but I can not use JEDI to format the PAS file.  The problem occurs when I add "wsFullScreen". Without that, I can use JEDI. I have no idea how to fix JEDI to correct this. ---------------------------------------------------------------------- Thaddy · 2024-03-28 17:05 Of course you can not even use the set....Unless you are well versed in quantum theory... Not good enough to prove your point. Focussing on the SQL confuses JEDI with (* and *). Solution/workaround is to use spaces, like ( * ); Problem is that the JEDI jcf parser does not maintain enough state while it is in a string and that is a bug. It should know it has to ignore the contents of any - literal or not - string until the string is terminated. Btw It will get a lot worse in trunk! too many new language features with accompanying syntax. ---------------------------------------------------------------------- bobonwhidbey · 2024-03-28 18:10 The source of the problem with JEDI had nothing to do with "(*" .  The entire error seems to be caused by JEDI not handling a SET definition correctly. This works in JEDI: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TestSET: set of tWindowState = [wsNormal..wsMinimized]; This does not: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TestSET: set of tWindowState = [wsNormal..wsMinimized,wsFullScreen]; ---------------------------------------------------------------------- bytebites · 2024-03-28 18:49 You need to fix this piece from /components/jcf2/Parse/BuildParseTree.pas around line 1700. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TBuildParseTree.RecogniseArrayConstant;begin  // ArrayConstant -> '(' TypedConstant/','... ')'   PushNode(nArrayConstant);   Recognise([ttOpenBracket,ttOpenSquareBracket]);   RecogniseTypedConstant;  while (fcTokenList.FirstSolidTokenType = ttComma) do  begin    Recognise(ttComma);    RecogniseTypedConstant;  end;   Recognise([ttCloseBracket,ttCloseSquareBracket]);   PopNode;end;   Plug this code in Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if fcTokenList.FirstSolidTokenType = ttDoubleDot then  begin    Recognise(ttDoubleDot);    RecogniseExpr(False);  end; ---------------------------------------------------------------------- DomingoGP · 2024-03-28 20:27 Opened issue in bug tracker https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40871 and fixed in trunk commit a326522d9357b4465336a0b93e63e96cf3e3cd77 I have applied the changes proposed by bytebites slightly modified. Thanks for reporting and for the patch. ---------------------------------------------------------------------- Thaddy · 2024-03-28 20:30 tnx