Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3026 closed Bug (Fixed)

Au3Check unexpectedly trims Const definitions to 63 characters and reports false errors

Reported by: Tomasz.Szreder@… Owned by: Jos
Milestone: 3.3.13.21 Component: Au3Check
Version: 3.3.12.0 Severity: None
Keywords: Const Au3Check Cc:

Description

In our test automation system we have a number of AutoIt3 script files containing only lots of constant definitions and included elsewhere. They are automatically compiled from application resource files and often contain very long constant names (to avoid collisions and give a hint of their contents).

Below is a trimmed-down example of such a file:

Global Const $LongLongName3456789_123456789_123456789_123456789_123456789_123  = 123
Global Const $LongLongName3456789_123456789_123456789_123456789_123456789_1234 = 1234

Now, when I run Au3Check.exe -d -w 7 "LongConstNames.au3", I get an error stating a redeclaration.

AutoIt3 Syntax Checker v3.3.13.20  Copyright (c) 2007-2013 Tylo & AutoIt Team

"(...)LongConstNames.au3"(2,86) : error: $LongLongName3456789_123456789_123456789_123456789_123456789_123 previously declared as a 'Const'.
Global Const $LongLongName3456789_123456789_123456789_123456789_123456789_1234 = 1234
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
(...)LongConstNames.au3 - 1 error(s), 0 warning(s)

There are no errors when I remove the Const keyword. The latest Beta 3.3.13.20 also exhibits this problem.

Please raise the internal Const name length limit to something larger, like 255 or so. Should be fairly simple to fix, and also unit-testable. Thanks!

Regards
Tomasz Szreder
Tomasz.Szreder@…

Attachments (0)

Change History (16)

comment:1 Changed 9 years ago by Jos

  • Owner set to Jos
  • Status changed from new to accepted

There seems to be a limit of 64 characters currently indeed. That it hasn't come up yet till know probably says something about your request and the exceptional length you seem to be using for your variables.
It can be enlarged but will require proper testing as I have no idea if there are any consequences to the stacksizes etc with the utilisation of YACC & FLEX.

On the fence as to whether we really should do this and to what max length.

Jos

comment:2 Changed 9 years ago by mLipok

Maybe this looks funny but just today I come to the same problem:

Globa Enum _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_Miejscowosc, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_MiejscowoscKodTerryt, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_Ulica, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_UlicaKodTerryt, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_NumerDomu, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_NumerLokalu, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_Gmina, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_GminaKodTerryt, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_MscKodPocztowy, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_Komentarz, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_DataZameldowania, _
$g__eSYSTEMXYZ_HTML_API__DaneZameldowania_AktualnyPobytStaly_DataAktualizacji, _
....
....

In my project that I'm doing such enumeration more, and their syntax is dependent on the location of the data in an HTML page.
If you need to carry out tests, then there's a chance.

btw.
@Tomasz.
Pozdrawiam, rodaku
Regards, countryman

mLipok

comment:3 Changed 9 years ago by Jos

Well it probably is me being lazy or something but I have done quite some programming in my life but can assure you I've never ever used fieldnames with a length like that as that make the program pretty unreadable for me.
I have made a version of au3check that allows a length of 128 characters and will first do some more testing before making that available for other to test with.

Jos

comment:4 Changed 9 years ago by Tomasz Szreder <Tomasz.Szreder@…>

Thanks for a quick response!

Actually, there is an easy workaround to this problem - I could replace "Global Const" with just the "Global" (they're not altered anyway), and Au3Check stops complaining. We don't need the long-named definitions to be Const, it just feels right to define them as constants and not variables.

Length-wise: the original resource-based constants (with long names) are machine-generated (call them "private" sort of), but we only pick those that are needed in the autotest scripts and redeclare them into more reader-friendly names (2nd layer of resources - "public" definitions). So I agree using *very* long names in a source code is a bad programming practice, but we would still find it useful to define a 90-characters-long constant once in a while.

Thanks for considering. I would gladly put the new Au3Check to some heavy testing when you share it.

Regards and pozdrowienia, too :)
Tomek

comment:5 Changed 9 years ago by Jos

The issue isn't about Const but more about just checking the first 64 characters of a variable-name to make them unique. Agree it appears when one is defined a Const and the next as normal as AU3check "thinks" it is checking the same name.
I have uploaded this version of AU3CHeck in a separate directory so please give it a good spin and see if all is well now: https://www.autoitscript.com/autoit3/scite/download/beta_SciTE4AutoIt3/au3check-beta/Au3Check.exe

Jos

comment:6 Changed 9 years ago by Tomasz Szreder <Tomasz.Szreder@…>

I've just given it several runs on a number of our test scripts and compared output with 3.3.12.0 and 3.3.13.20. The misleading errors are now gone (good!) and (almost) all the other found errors/warnings are still in place, so no regressions I believe.

In fact, I've just found the latest beta to no longer report another not-so-much-of-an-error, which .12.0 did:

"...\common\testcore\EmailNotify.au3"(24,5) : error: missing separator character before keyword.
			.To
			~^

But this improvement is also visible in the previous beta, .13.20.

Great job! Many thanks for the quick resolution. Green light from me on making this widely available.

Tomek

comment:7 Changed 9 years ago by mLipok

only first line is ok
all others line give me an additional errors

Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt1 = ''
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
Global Enum _
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt3, _
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "Z:\TOOLs\Macro\PROGRAMY\KK_PESELNET\test_Au3.au3"
+>14:02:37 Starting AutoIt3Wrapper v.15.503.1200.1 SciTE v.3.5.4.0   Keyboard:00000415  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0415)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\MichaԜAppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\MichaԜAppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.13.21)  from:C:\Program Files (x86)\AutoIt3  input:Z:\TOOLs\Macro\PROGRAMY\KK_PESELNET\test_Au3.au3
"Z:\TOOLs\Macro\PROGRAMY\KK_PESELNET\test_Au3.au3"(2,85) : error: syntax error
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"Z:\TOOLs\Macro\PROGRAMY\KK_PESELNET\test_Au3.au3"(2,85) : error: Statement cannot be just an expression.
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"Z:\TOOLs\Macro\PROGRAMY\KK_PESELNET\test_Au3.au3"(4,74) : error: $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKo previously declared as a 'Const'.
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt3,
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"Z:\TOOLs\Macro\PROGRAMY\KK_PESELNET\test_Au3.au3"(5,74) : error: $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKo previously declared as a 'Const'.
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Z:\TOOLs\Macro\PROGRAMY\KK_PESELNET\test_Au3.au3 - 4 error(s), 0 warning(s)
!>14:02:37 AU3Check ended. Press F4 to jump to next error.rc:2
+>14:02:37 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.6703

comment:8 Changed 9 years ago by mLipok

btw.
If this is not a problem,
@Tomaszu as I can not find your @member title on the forum, please send me PM in the forum.

I like to speak in Polish language with my countryman, about AutoIt.

comment:9 Changed 9 years ago by Tomasz Szreder <Tomasz.Szreder@…>

@mLipok
I think you have two errors in the source code you posted. 1) You're declaring a const without a value, and 2) you're redefining ..._MscKodTeryt2. Try the following code (it gives me no errors):

Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt1 = ''
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2 = ''
Global Enum _
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt3, _
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt4

(I haven't had a chance to post at the forum yet - I don't have an account there, sorry :) )

comment:10 Changed 9 years ago by Tomasz Szreder <Tomasz.Szreder@…>

@mLipok
OK, so I read once again and now I get what you meant. You were expecting *2* errors reported and you got *4* of them. The thing is, you must be running older Au3Check, becase when I run it with .13.21, I get the following output (which is closer to expectations):

AutoIt3 Syntax Checker v3.3.13.21  Copyright (c) 2007-2013 Tylo & AutoIt Team

"(...)test3.au3"(8,85) : error: syntax error
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"(...)test3.au3"(8,85) : error: Statement cannot be just an expression.
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
test3.au3 - 2 error(s), 0 warning(s)

When I fix the first one and run .13.21 again, I get:

AutoIt3 Syntax Checker v3.3.13.21  Copyright (c) 2007-2013 Tylo & AutoIt Team

"(...)test3.au3"(11,74) : error: $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2 previously declared as a 'Const'.
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
test3.au3 - 1 error(s), 0 warning(s)

So, more or less all is good now in .13.21 in my view. Try to run Au3Check--3.3.13.21.exe -d -w 7 script.au3 in the command prompt.

Regards
Tomek

comment:11 Changed 9 years ago by Jos

I've updated the version number to .13.22 and uploaded it to the same place, so we are sure we are looking at the same thing.
So, more or less all is good now in .13.21 in my view.
Not sure what that really means. To me it is either working or not working now. :)

Jos

Last edited 9 years ago by Jos (previous) (diff)

comment:12 Changed 9 years ago by Tomasz Szreder <Tomasz.Szreder@…>

When I download https://www.autoitscript.com/autoit3/scite/download/beta_SciTE4AutoIt3/au3check-beta/Au3Check.exe and run it, it reports .13.21. Should it now be .13.22? I got confused as to where to take the latest Au3Check beta from.

Anyway, I've confirmed .13.21 solves problem bug #3026 for me.

As for the "more or less correct" - I think that for the source code posted by mLipok (#comment:7) build .13.21 works fine for long const names, but does not correctly specify what are the exact errors (problem different from #3026).

So, when the following code is Au3Check'ed:

Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt1 = ''
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
Global Enum _
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt3, _
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2

the output is

AutoIt3 Syntax Checker v3.3.13.21  Copyright (c) 2007-2013 Tylo & AutoIt Team

"D:\qa-Automated-AV\AutoClick\au3checkBetaTests\test3.au3"(2,85) : error: syntax error
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"D:\qa-Automated-AV\AutoClick\au3checkBetaTests\test3.au3"(2,85) : error: Statement cannot be just an expression.
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
test3.au3 - 2 error(s), 0 warning(s)

whereas I would expect somthing like

"D:\qa-Automated-AV\AutoClick\au3checkBetaTests\test3.au3"(2,85) : error: Statement cannot be just an expression.
Global Const $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"D:\qa-Automated-AV\AutoClick\au3checkBetaTests\test3.au3"(5,74) : error: $g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2 previously declared as a 'Const'.
		$g_ePORTALXYZ_HTML_API_DaneZameldowania_AktualnyPobytStaly_MscKodTeryt2
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

It does report errors when there are some, just does not find the redeclaration problem at once. It's fine with me, because when the first error is fixed (the constant is assigned a value), the other problem shows up, too.

So maybe this is another bug (minor), or "working as designed", but totally acceptable. Hope this clarifies things.

I've already started to use 3.3.13.21 to track down syntax errors in our autotest framework and will put it into continuous integration system some time soon. I find the tool very useful now that it doesn't report false errors (for me).

Thanks again,
Tomek

comment:13 Changed 9 years ago by mLipok

Replying to Jos:

I've updated the version number to .13.22 and uploaded it to the same place, so we are sure we are looking at the same thing.
So, more or less all is good now in .13.21 in my view.
Not sure what that really means. To me it is either working or not working now. :)

Jos

In a short test, actually this ".13.22" looks like works, as expected.
Today and tomorrow I have many work to to so I be using this, and report if find any problem with this long names feature.

comment:14 Changed 9 years ago by Jos

Ha... I only updated the PE header file version but forgot the console message version.
That should be fixed now.

Jos

comment:15 Changed 9 years ago by Jos

  • Milestone set to 3.3.13.21
  • Resolution set to Fixed
  • Status changed from accepted to closed

Fixed by revision [11296] in version: 3.3.13.21

comment:16 Changed 9 years ago by Jos

Committed the change and move the file into the regular beta directory.

Jos

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jos.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.