Forum > General

Unexpected lack of error message

(1/2) > >>

440bx:
Hello,

Consider the following code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program NoErrorOnMissingOp; const a = 1; b = 2; c = 3; {$if     (a <> 1)     (b <> 0) or     (c <> 3)}   {$MESSAGE 'a message here'}{$endif} var  v : integer; begin  v := a + b + c;   readln;end.    Note the missing operator ("or" in this case) on line 9.  The compiler does not emit a message about the missing operator.  Of course, as a result, the expression does not work as expected, i.e, no message is displayed.

It would have been nice for the compiler to emit some sort of message about a "likely" missing operator.

Thaddy:
This is likely due to the fact that after the first complete match, everything else is a comment.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$if     (a <> 1)     // complete expression     (b <> 0) or  // comment     (c <> 3)     // comment}This behavior is documented. Have to look it up, though. It has come up multiple times before.
Delphi 12.1 throws "E2066 Missing operator or semicolon"  so there is some ground to get this fixed.

n7800:
It seems the documentation doesn't mention anything about this. I couldn't find anything in the programmer's manual for the word "comment", so I created a request to add it to the documentation.

I only found a small mention on the wiki.

n7800:

--- Quote from: Thaddy on November 09, 2025, 01:54:36 pm ---Delphi 12.1 throws "E2066 Missing operator or semicolon"  so there is some ground to get this fixed.

--- End quote ---

I hope you'll create a issue for FPC?

Thaddy:
It is only for {$ifdef} it seems, but the behavior is the same for {$if}:
https://www.freepascal.org/docs-html/current/prog/progsu31.html

Navigation

[0] Message Index

[#] Next page

Go to full version