View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0037818||Lazarus||IDE||public||2020-09-26 13:45||2020-09-27 09:31|
|Reporter||Juha Manninen||Assigned To|
|Product Version||2.1 (SVN)|
|Summary||0037818: Code completion for "while" and "with" variable wrongly adds a semicolon after "do".|
|Description||If you have |
var obj: TObject;
typing "with ob", then Ctrl-Space, then Enter to select "obj" completes the code as :
with obj do;
The semicolon at the end must be removed manually if you want to do anything useful with it.
The same thing happens with a while loop completion. A semicolon is added there, too.
This extra semicolon is nasty because the compiler does not complain about it. A programmer may wonder for long why his code does not work before noticing it.
|Additional Information||This was originally mentioned by user Jo-Anna in #lazarus-ide chat.|
|Tags||No tags attached.|
|Fixed in Revision|
||The semicolon is required by fpc unless next token is an "end". Why do you think you must delete it?|
The semicolon should come only after the next expression, not right after the "do".
Assuming var butt: TButton;
Placed in some Form's event handler, these 2 clauses do different things :
with butt do
with butt do;
The first one is probably what a programmer meant but the compiler does not complain about the second one.
Ah, when changing an existing statement into a with block.
So, it must not insert a semicolon if next statement is indented.
No. Typing new code.
Assuming you have defined var butt: TButton;
Type new code "with but", then Ctrl-Space, then Enter to select "butt", and you get :
with butt do;
Note the semicolon at the end. A programmer may fail to notice it and type an expression in the next line thinking it is affected by "with butt do".
1. It seems to me the "fail to notice" argument works here in both ways.
2. Newbies tend to forget semicolons, so in general it is a good thing to auto add them.
3. For-do, while-do also add semicolons. Do you intend to omit them there too?
I forgot "for-do" loop. Yes, the completion of all 3 (with, while, for) should be consistent.
IMO the semicolon is in a wrong place even if noticed by a programmer. It must be deleted by BackSpace, or the cursor must be moved in front of it and a Space/NewLine must be added.
The semicolon never does anything good when directly following "do" ("do;").
Without the semicolon the programmer could write more code immediately.
|2020-09-26 13:45||Juha Manninen||New Issue|
|2020-09-26 13:52||Juha Manninen||Description Updated||View Revisions|
|2020-09-26 13:52||Juha Manninen||LazTarget||=> -|
|2020-09-26 13:57||Mattias Gaertner||Note Added: 0125872|
|2020-09-26 14:26||Juha Manninen||Description Updated||View Revisions|
|2020-09-26 21:16||Juha Manninen||Note Added: 0125883|
|2020-09-26 21:52||Mattias Gaertner||Note Added: 0125884|
|2020-09-26 22:13||Juha Manninen||Note Added: 0125885|
|2020-09-26 22:55||Mattias Gaertner||Note Added: 0125887|
|2020-09-27 09:31||Juha Manninen||Note Added: 0125893|