| View previous topic :: View next topic |
| Author |
Message |
Lexikos
Joined: 17 Oct 2006 Posts: 2486 Location: Australia, Qld
|
Posted: Sun Sep 16, 2007 6:24 pm Post subject: function library - obscure/incorrect error message |
|
|
Let the test script tell this minor tale:
| Code: | LibTest_DoesntExist()
LibTest_DoesExist()
{
} |
| Quote: | ---------------------------
LibTest.ahk
---------------------------
Error at line 3 in #include file "...\AutoHotkey\Lib\LibTest.ahk".
Line Text: LibTest_DoesExist()
Error: Duplicate function definition.
The program will exit.
---------------------------
OK
--------------------------- | Expected result: | Quote: | ---------------------------
LibTest.ahk
---------------------------
Error: Call to nonexistent function.
Specifically: LibTest_DoesntExist()
Line#
---> 001: LibTest_DoesntExist()
The program will exit.
---------------------------
OK
--------------------------- | It seems because the nonexistent function is prefixed with the name of the script, AutoHotkey tries to include the script within itself. (I encountered this while testing a script in my function library, after renaming a function.) |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Nov 11, 2007 11:02 pm Post subject: |
|
|
Sorry for the late reply. The bug is easy to reproduce thanks to your easy example.
Given the rarity of this bug and the fact that its only consequence is a misleading error message, perhaps it wouldn't be worth the added code size to fix it. Comments are welcome.
Thanks. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2486 Location: Australia, Qld
|
Posted: Mon Nov 12, 2007 1:30 am Post subject: |
|
|
Normally, I would agree. However...
| lexikos wrote: | Actually, only one change would be required; in Script::FindFuncInLibrary(): | Code: | | if (!LoadIncludedFile(sLib[i].path, true, false)) | to | Code: | | if (!LoadIncludedFile(sLib[i].path, false, false)) | There's a comment on that line that explains why true is passed: | Quote: | | For performance, pass true for allow-dupe so that it doesn't have to check for a duplicate file (seems too rare to worry about duplicates since by definition, the function doesn't yet exist so it's file shouldn't yet be included). | I tested the change with corrupt's example. The message given is: | Quote: | ---------------------------
libtest.ahk
---------------------------
Error: Call to nonexistent function.
Specifically: fun_notsomuch()
Line#
001: fun()
002: fun_wow()
---> 003: fun_notsomuch()
003: Exit
001: {
002: MsgBox,hmm
003: Return
004: }
006: {
007: MsgBox,wow
The program will exit.
---------------------------
OK
--------------------------- |
|
Posted in StdLib bug (thread started by majkinetor a couple days after this one. ) |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3615 Location: Belgrade
|
Posted: Mon Nov 12, 2007 9:56 am Post subject: |
|
|
I think this bug should be fixed. Its not rare at all if you develop stdlib functions. _________________
 |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6511 Location: Pacific Northwest, US
|
Posted: Mon Nov 12, 2007 5:25 pm Post subject: |
|
|
I also agree. simple fix, no downside, reasonably common problem for developers. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Tue Nov 13, 2007 12:23 pm Post subject: |
|
|
I hadn't realized the fix was so simple. Due to the risk of introducing new bugs, I'm usually wary of making changes that don't add significant value for 99% of users. But this change seems low-risk.
Although script-loading performance will be slightly reduced (especially for scripts with dozens of included files), you all say it's important enough, so the change will be made.
Thanks for the testing and analysis. |
|
| Back to top |
|
 |
|