Recent

Author Topic: Problem (bug?) with dotted unit names and default name spaces.  (Read 446 times)

glorfin

  • Full Member
  • ***
  • Posts: 108
I have two units, LMath.uPointsVec.pas in a package LMComponents, and FitLogExp in the project (ConstrFit).
Both of them use the same type TRealPoint, defined in lmath.uTypes unit.

In LMath.uPointsVec:
uses  LMath.uTypes; // complete identifier

In FitLogExp:
uses uTypes; // partial identifier, but project contain -FNlmath switch.

Line in FitLogExp:
DataPoints.Append(Pt); //DataPoints is of type TPoints, defined in uPointsVec

leads to following error message:
In FitLogExp.pas(62,25) Error: Incompatible type for arg no. 1: Got "LMATH.UTYPES.TRealPoint", expected "LMATH.UTYPES.TRealPoint"

If I use complete identifier in uses clause of FitLogExp, everything works fine.
« Last Edit: August 22, 2020, 03:18:55 pm by glorfin »

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problem (bug?) with dotted unit names and default name spaces.
« Reply #1 on: August 22, 2020, 02:11:50 am »
In FitLogExp.pas(62,25) Error: Incompatible type for arg no. 1: Got "LMATH.UTYPES.TRealPoint", expected "LMATH.UTYPES.TRealPoint"
You got to love such 'explanatory' errors  :D

I do not know for sure if it was intended to have the distinction, but no matter what: it is a bug. Either the distinction is intended, in which case the error message is ambiguous or it is not intended to have the distinction and that fact in itself is the bug.
« Last Edit: August 22, 2020, 02:13:21 am by TRon »

glorfin

  • Full Member
  • ***
  • Posts: 108
Re: Problem (bug?) with dotted unit names and default name spaces.
« Reply #2 on: August 22, 2020, 02:32:07 am »
Well, if a type is incompatible with itself, it looks very much like a bug. Most probably, compiler routine which resolves unit names, first creates a list of units, found directly, afterwards it searches once more for units, combining name space provided in -FNxxxx and unit name in "uses" clause, but then forgets to test if this unit was already found, and ends up with two distinct items for the same unit.
« Last Edit: August 22, 2020, 03:19:15 pm by glorfin »

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problem (bug?) with dotted unit names and default name spaces.
« Reply #3 on: August 22, 2020, 02:40:39 am »
Your analysis reads very plausible, but fact is that it doesn't matter what caused it. It is just plain wrong (any which way you view/explain it, if even for undocumented behaviour) :)

Nice find btw, even knowing that what you are working on made it just a matter of time.

Please file a report if you are able to.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2138
  • Compiler Developer
Re: Problem (bug?) with dotted unit names and default name spaces.
« Reply #4 on: August 22, 2020, 12:29:06 pm »
Please file a report if you are able to.

And please provide a complete, but small and self contained example.

glorfin

  • Full Member
  • ***
  • Posts: 108
Re: Problem (bug?) with dotted unit names and default name spaces.
« Reply #5 on: August 22, 2020, 07:36:48 pm »
Done. Issue 0037622.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2138
  • Compiler Developer
Re: Problem (bug?) with dotted unit names and default name spaces.
« Reply #6 on: August 23, 2020, 01:45:59 pm »
Thanks

 

TinyPortal © 2005-2018