Page 1 of 1

Variable already declared

Posted: Tue Jan 13, 2026 10:39 am
by Sergey

Code: Select all

EnableExplicit
Define abc.q
abc.q = 2
abc = 5
No error

Code: Select all

EnableExplicit
Define abc.q
abc.q = 2
abc.i = 5
[13:40:14] [COMPILER] Line 4: Variable already declared with another type: abc.

With type abc :shock:
Stop, abc - variable's name, not variable type


// Moved from "Bugs - Windows" to "Coding Questions" (Kiffi)

Re: Variable already declared

Posted: Tue Jan 13, 2026 11:13 am
by Little John
Sergey wrote: Tue Jan 13, 2026 10:39 am

Code: Select all

EnableExplicit
Define abc.q
abc.q = 2
abc.i = 5
[13:40:14] [COMPILER] Line 4: Variable already declared with another type: abc.
This is short for: “The following variable is already declared with another type: abc.”
Sergey wrote: Tue Jan 13, 2026 10:39 am With type abc :shock:
Stop, abc - variable's name, not variable type
The message does not write that abc is the variable's type.

Re: Variable already declared

Posted: Tue Jan 13, 2026 11:47 am
by Sergey
Оh, that's for sure
I read it as if it was a different type
Sorry, topic can be deleted

Re: Variable already declared

Posted: Tue Jan 13, 2026 1:44 pm
by Fred
I will try to make the message clearer

Re: Variable already declared

Posted: Tue Jan 13, 2026 2:05 pm
by Sergey
Maybe... Variable abc already declared with type quad

Re: Variable already declared

Posted: Wed Jan 14, 2026 7:14 am
by TI-994A
Sergey wrote: Tue Jan 13, 2026 2:05 pm Maybe... Variable abc already declared with type quad
Technically, this should be sufficient:

Code: Select all

Line 4: Variable already declared: abc

More succinct, less confusion. IMHO. :wink:

Re: Variable already declared

Posted: Wed Jan 14, 2026 9:54 am
by Fred
Changed into:
Variable 'abc' already declared with another type.

Re: Variable already declared

Posted: Wed Jan 14, 2026 11:28 am
by Little John
Fred wrote: Wed Jan 14, 2026 9:54 am Changed into:
Variable 'abc' already declared with another type.
That is more clear. :thumbsup:

Re: Variable already declared

Posted: Wed Jan 14, 2026 8:48 pm
by charvista
EnableExplicit
Define abc.q
abc.q = 2
abc = 5
When you use a variable without extension, it is the extension type that was used when you defined it that will be used; you defined it as .q so the abc (without .q) is the same as abc.q, and if you run it with Debug abc and Debug abc.q you will see that you have the same result: 5
EnableExplicit
Define abc.q
abc.q = 2
abc.i = 5
Here you have an error, because you have already defined abc as type .q so trying to define abc as type .i is a name mismatching: you cannot change the type of variable on the fly.

One thing to keep in mind: when a variable is defined without type, then the .i type will be the default.
Define abc
is the same as
Define abc.i
(in the case you have not already defined it as a .q, of course: it is the first definition that will given to a variable that counts)

Re: Variable already declared

Posted: Wed Jan 14, 2026 8:53 pm
by charvista
Little John wrote: Wed Jan 14, 2026 11:28 am
Fred wrote: Wed Jan 14, 2026 9:54 am Changed into:
Variable 'abc' already declared with another type.
That is more clear. :thumbsup:
When speaking about the error message, yes, that is more clear, but "Variable 'abc' already declared as type .q' is more precise...

Re: Variable already declared

Posted: Thu Jan 15, 2026 7:26 am
by Sergey
charvista wrote: Wed Jan 14, 2026 8:53 pm When speaking about the error message, yes, that is more clear, but "Variable 'abc' already declared as type .q' is more precise...
I'm agree with you 100%
The user sees the specified type and can easily correct the error