Bug in Harbour ATAIL() [False report]

Post Reply
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Bug in Harbour ATAIL() [False report]

Post by Enrico Maria Giordano »

This is a sample of the problem:

Code: Select all | Expand

FUNCTION MAIN()

    LOCAL aArray[ 10 ]

    ATAIL( aArray ) = 123

    ? aArray[ 10 ]

    INKEY( 0 )

    RETURN NIL


I get

Code: Select all | Expand

Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
BUG.prg(5) Error E0022  Invalid lvalue '()'
1 error


EMG
User avatar
Antonio Linares
Site Admin
Posts: 42512
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Antonio Linares »

Dear Enrico,

You can not assign a value to a value, so it seems as the error is correct. It is like doing:

nil = nil

Anyhow, if the returned value is an object with a redefined "=" or ":=" operator, then it should accept it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Enrico Maria Giordano »

From Clipper docs:

ATAIL()
Return the highest numbered element of an array
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Syntax

ATAIL(<aArray>) --> Element

Arguments

<aArray> is the array.

Returns

ATAIL() returns either a value or a reference to an array or object.
The array is not changed.

Description

ATAIL() is an array function that returns the highest numbered element
of an array. It can be used in applications as shorthand for
<aArray>[LEN(<aArray>)] when you need to obtain the last element of an
array.

Examples

þ The following example creates a literal array and returns that
last element of the array:

aArray := {"a", "b", "c", "d"}
? ATAIL(aArray) // Result: d

Files: Library is CLIPPER.LIB.


So it should be perfectly legal to use

Code: Select all | Expand

ATAIL( aArray ) = xValue


just like you can use

Code: Select all | Expand

aArray[LEN(aArray)] = xValue


EMG
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Enrico Maria Giordano »

I forgot to mention that this works fine using xHarbour:

Code: Select all | Expand

ATAIL( aArray ) = xValue


EMG
User avatar
Antonio Linares
Site Admin
Posts: 42512
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Antonio Linares »

Dear Enrico,

Harbour and xHarbour source code for ATail() are the same, so we need to keep searching where the difference comes from.
I would say that the compiler parser does not allows it, so we need to modify Harbour syntax rules.

You should report this Harbour bug on Google groups Harbour developers and the group will decide

thank you
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Enrico Maria Giordano »

Sorry, I'm not following Harbour development. I don't even know if this bug has been corrected in the latest version.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 42512
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Antonio Linares »

It has not been corrected as lastest commit was on Apr 28, 2021:

https://github.com/harbour/core/commits/master
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42512
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Antonio Linares »

Dear Enrico,

I just reported it into the Harbour's developers group:

https://groups.google.com/g/harbour-devel/c/ZPvgH-Lt1sY/m/w5z0BUQSAgAJ

many thanks for your great feedback
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42512
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Antonio Linares »

Dear Enrico,

There are already four answers in the conversation, please review them
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Enrico Maria Giordano »

Unfortunately, I can't test it with Clipper. Can you?

EMG
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Bug in Harbour ATAIL()

Post by Enrico Maria Giordano »

Tried with Clipper: same error. Ok, I'm going to change my source code...

EMG
Post Reply