Incorrect error message on Debug a = a+1

Just starting out? Need help? Post your questions and find answers here.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Incorrect error message on Debug a = a+1

Post by blueznl »

Very minor error message:

Debug a=a+1 reports:

Line 14: Comparisons (=, <, >, =< and >=) are only supported with keywords like If, While, Until or within Bool().

However, a=a+1 in this case isn't a comparison but an evaluation / assignment 8)

(I just can imagine you will ignore this one 8) )
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Demivec
Addict
Addict
Posts: 4091
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Incorrect error message on Debug a = a+1

Post by Demivec »

The error reported as 'Comparisons (=, <, >, =< and >=) are only supported with keywords like If, While, Until or within Bool().' makes sense when the code be interpreted like this (imaginary parenthesis added to emphasize interpretation):

Code: Select all

Debug (a=a)+1
Assignment is a statement and not an operator and so can't be included in any other statements or expressions, including debug statements (I am ignoring the syntactic sugar that combines assignment along with a math operator, i.e. a + 1 for a = a + 1). So it does not seem to be necessary to guard against it in the list of errors generated for other statements, IMHO.

I don't think there is a problem with the way it currently is. What would you suggest the error mesage say instead?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Incorrect error message on Debug a = a+1

Post by Josh »

blueznl wrote:However, a=a+1 in this case isn't a comparison but an evaluation / assignment 8)
That's correct, but in connection with Debug the whole a=a+1 is a rhs term and so the '=' can only be interpreted as a comparsion sign. No bug.
sorry for my bad english
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Incorrect error message on Debug a = a+1

Post by Little John »

Josh wrote:in connection with Debug the whole a=a+1 is a rhs term and so the '=' can only be interpreted as a comparsion sign. No bug.
That's right.

If a should be incremented by 1, and then the value of a should be shown, it must read like this:

Code: Select all

a = a + 1    ; or just a + 1
Debug a
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Incorrect error message on Debug a = a+1

Post by blueznl »

As I said, it is not important 8)

I just accidentally entered a 'Debug' in the wrong line of code, so (just an example below!)

Code: Select all

a = 5
a = a+1
If a > 10
became

Code: Select all

a = 5
Debug a = a+1
If a > 10
So you can see how my PERCEPTION (cheap cop-out, I know) was it was an assignment.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Incorrect error message on Debug a = a+1

Post by Dude »

blueznl, your Survival Guide has this very example in it, here:

http://ninelizards.com/purebasic/pureba ... bug_output

But your explanation of it says that "Debug a = a+1" always outputs 1, instead of saying it raises a Bool() error.

You can see this just above the "11.5 Variable Viewer" heading. FYI. ;)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Incorrect error message on Debug a = a+1

Post by blueznl »

Another part that needs a rewrite... The guide is beginning to age... :cry:
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply