Recent

Author Topic: Improvement request  (Read 1219 times)

440bx

  • Hero Member
  • *****
  • Posts: 3875
Improvement request
« on: February 10, 2024, 03:06:55 pm »
Hello,

FPC v3.2.2 currently emits an "Error: Illegal expression" message when it encounters an assignment statement with a missing ":", i.e,
Code: Pascal  [Select][+][-]
  1. SomeVar = avalue;   { illegal expression - note missing ":" }

This is an easy mistake to make when porting C code to Pascal.  More often than not, the cause of the problem is evident (the missing ":") but, on occasion, after porting many lines of code, the reason can be overlooked resulting in a waste of time.

The request is therefore: if at all possible improve the error message to something along the lines of "possible ":" missing in assignment statement" or something along those lines.

Thank you.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.1 both fixes) on Windows 7 SP1 64bit.

Kays

  • Hero Member
  • *****
  • Posts: 568
  • Whasup!?
    • KaiBurghardt.de
Re: Improvement request
« Reply #1 on: February 10, 2024, 11:40:02 pm »
The word note is in the imperative mood. “Pay attention!” Maybe you can’t see it but there ain’t no colon.

Your wording on the other hand is pretty suggestive. We don’t know what’s missing; there are multiple valid hypotheses.
Yours Sincerely
Kai Burghardt

440bx

  • Hero Member
  • *****
  • Posts: 3875
Re: Improvement request
« Reply #2 on: February 11, 2024, 12:41:40 am »
there are multiple valid hypotheses.
My hypothesis is that you should follow Lincoln's advice.  It would serve you well.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.1 both fixes) on Windows 7 SP1 64bit.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8741
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Improvement request
« Reply #3 on: February 15, 2024, 04:40:24 pm »
The request is therefore: if at all possible improve the error message to something along the lines of "possible ":" missing in assignment statement" or something along those lines.
In theory, it should be possible, as an explicitly handled case, like this one where it specifically handles proc():=. In this case, instead of falling into an else clause of a case statement, a case to handle _EQ should be added.

Thaddy

  • Hero Member
  • *****
  • Posts: 14014
  • Probably until I exterminate Putin.
Re: Improvement request
« Reply #4 on: February 15, 2024, 06:34:39 pm »
That is not an improvement, it is a fallacy.
"Fixing" mistakes by changing syntax is a mistake.
Not to mention that assignment does not  equal equality.
The same is the case in C , = vs ==. so shut up is the most kind expression I could find.
« Last Edit: February 15, 2024, 06:37:55 pm by Thaddy »
Specialize a type, not a var.

xixixi

  • New Member
  • *
  • Posts: 25
Re: Improvement request
« Reply #5 on: February 15, 2024, 08:33:09 pm »
I think it's a great improvement. If the statement is an (illegal) equality expression, a note could be added to "Illegal expression", like "Did you mean an assignment ':='?".

440bx

  • Hero Member
  • *****
  • Posts: 3875
Re: Improvement request
« Reply #6 on: February 15, 2024, 09:35:52 pm »
That is not an improvement, it is a fallacy.
You and Kay should get a room... make each other happy <chuckle>
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.1 both fixes) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14014
  • Probably until I exterminate Putin.
Re: Improvement request
« Reply #7 on: February 15, 2024, 09:48:19 pm »
That is not an improvement, it is a fallacy.
You and Kay should get a room... make each other happy <chuckle>
And you should be able to distinguish between assignment and comparison.
Specialize a type, not a var.

dbannon

  • Hero Member
  • *****
  • Posts: 2750
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Improvement request
« Reply #8 on: February 16, 2024, 03:09:53 am »
Oh, come on, 440bx is not suggesting the compiler should go off and edit your source or anything like that. Just issue a more meaningful message. One that would be more helpful in the vast majority of cases.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018