Recent

Author Topic: Dotted unit names and fatal errors  (Read 6677 times)

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Dotted unit names and fatal errors
« on: July 20, 2017, 10:31:07 pm »
With no dots, If a unit is not found, the ide shows the line of the resulting error. However with dotted unit names, sometimes the line number is shown, sometimes it not shown. Is it a bug of some sort?
Be mindful and excellent with each other.
https://github.com/cpicanco/

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: Dotted unit names and fatal errors
« Reply #1 on: July 22, 2017, 07:08:50 am »
With no dots, If a unit is not found, the ide shows the line of the resulting error. However with dotted unit names, sometimes the line number is shown, sometimes it not shown. Is it a bug of some sort?
Steps to reproduce?

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Dotted unit names and fatal errors
« Reply #2 on: July 23, 2017, 06:29:17 pm »
Ok. Sorry about that. I found this error while renaming some units in this project:

https://github.com/cpicanco/stimulus_control/commit/730cb16fabd2d3abe7abae65980dbc384fd05290

Unfortunatelly, I did not record the exact order.

1) Create some units and name them with no dots.
2) Use the units with different patterns (create some direct and indirect dependency among them)
3) Rename some of the units (save as, delete original file -> yes).
4) Try to compile and see if the linking error points to the right line

PS. I will try to create a test project following above steps.

Lazarus 1.8 RC3, FPC 3.0.3, OS Bunsen Labs (Debian 8 distro)
« Last Edit: July 23, 2017, 06:42:45 pm by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Dotted unit names and fatal errors
« Reply #3 on: July 23, 2017, 07:36:19 pm »
I made a project with quite a few  combinations like you wrote and can't reproduce it. The issue may be lazarus IDE specific (lpi file). (1.9/fpc 3.1.1 from today on Raspbian)
Code: Pascal  [Select][+][-]
  1. unit dotted.three;
  2. interface
  3. implementation
  4. uses dotted.one;
  5. end.
Code: Pascal  [Select][+][-]
  1. unit dotted.two;
  2. interface
  3. uses dotted.one;
  4. implementation
  5. end.
Code: Pascal  [Select][+][-]
  1. unit dotted.one;
  2. interface
  3. uses dotted.three;
  4. implementation
  5. uses dotted.two;
  6. end.
Code: Pascal  [Select][+][-]
  1. program dotted.project;
  2. {$mode objfpc}
  3. uses dotted.one;
  4. begin          
  5. end.

Note I also created deliberate assertion failures, rangecheck errors and a division by zero. Doesn't matter.
« Last Edit: July 23, 2017, 07:52:41 pm by Thaddy »
Specialize a type, not a var.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Dotted unit names and fatal errors
« Reply #4 on: July 23, 2017, 07:54:13 pm »
Here it is, reproduced:

Fatal: Can't find unit unit1_b used by unit1.namespace

You can open the project and hit F9.

Hopefully it is not something stupid.

PS.: Also, why lazarus will rename the unit names only in the .lpr file? Why not renaming all of them?
Be mindful and excellent with each other.
https://github.com/cpicanco/

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Dotted unit names and fatal errors
« Reply #5 on: July 23, 2017, 07:59:41 pm »
Perhaps i'm daft but where is unit1_b ?

You explicitly put it in your uses clause.

Code: [Select]
unit unit1.namespace;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;

var
  M1 : string = 'M1';

implementation

uses Dialogs, unit1_b;  <<<<<<<<<<<<

initialization
  ShowMessage(M1B);

end.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Dotted unit names and fatal errors
« Reply #6 on: July 23, 2017, 08:15:25 pm »
Hi molly, your IDE jumped to line?

uses Dialogs, unit1_b;

Sorry if I was not clear enough. The problem is that the IDE will not jump into this line.
Be mindful and excellent with each other.
https://github.com/cpicanco/

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Dotted unit names and fatal errors
« Reply #7 on: July 23, 2017, 08:27:18 pm »
Sorry if I was not clear enough. The problem is that the IDE will not jump into this line.

ah, ok. My bad. sorry for that.

I tested using the FPC (3.0.2) compiler (which locates the correct location of the error).


cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Dotted unit names and fatal errors
« Reply #8 on: July 23, 2017, 08:49:59 pm »
Well, this is very strange. Now I am receiving a different message:

unit1.namespace.pas(15,15) Fatal: Cannot find unit1_b used by unit1.namespace of the Project Inspector.

 :o
Be mindful and excellent with each other.
https://github.com/cpicanco/

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Dotted unit names and fatal errors
« Reply #9 on: July 23, 2017, 08:50:39 pm »
Also, why lazarus will rename the unit names only in the .lpr file? Why not renaming all of them?

Because most people do not want that, because unit x is something else as unit x.z and I may need both....

And I still can not reproduce it...
Specialize a type, not a var.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Dotted unit names and fatal errors
« Reply #10 on: July 23, 2017, 08:51:14 pm »
Maybe the problem occurs right after you use the "Save As" command?
Be mindful and excellent with each other.
https://github.com/cpicanco/

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Dotted unit names and fatal errors
« Reply #11 on: July 23, 2017, 08:52:37 pm »
Maybe the problem occurs right after you use the "Save As" command?
Delete your lpi (LPI, not LPR)  file and re-open the lpr file as project. Recompile.... That will create a new lpi if everything goes to plan...
« Last Edit: July 23, 2017, 08:55:03 pm by Thaddy »
Specialize a type, not a var.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Dotted unit names and fatal errors
« Reply #12 on: July 23, 2017, 08:54:11 pm »
Because most people do not want that, because unit x is something else as unit x.z and I may need both....

So, why renaming only inside the *.lpr then?
Be mindful and excellent with each other.
https://github.com/cpicanco/

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Dotted unit names and fatal errors
« Reply #13 on: July 23, 2017, 08:56:47 pm »
The lpr is the same as a pas file. It is the program file, not a configuration file. Your configuration is screwed... So delete that ( or rename to *.lpi.f.ckedup  :D)

I, for one, also use fp or geany,. fp doesn't know lpi at all. lpi is strictly Lazarus ide.

And all renaming and deleting should be done from a terminal window or a filemanager...... (outside of Lazarus...)
« Last Edit: July 23, 2017, 08:59:49 pm by Thaddy »
Specialize a type, not a var.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Dotted unit names and fatal errors
« Reply #14 on: July 23, 2017, 09:04:53 pm »
Quote
And all renaming and deleting should be done from a terminal window or a filemanager...... (outside of Lazarus...)

You say "Should" because the Save As funcionality is buggy? I am testing the save as functionality. I like it. I mean, It should work.

edit.: Also am I posting in the right place?? " Using the Lazarus IDE "
« Last Edit: July 23, 2017, 09:10:09 pm by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

 

TinyPortal © 2005-2018