|
Zhiroc Adept
Joined: 04 Feb 2005 Posts: 246
|
Posted: Sat Aug 02, 2008 8:27 pm
[2.35] Parsing of local variables with no space afterwards |
Consider the following example:
Code: |
$name1 = "John"
$name2 = "Bill"
#SH {$name1/$name2}
#SH {$name1's}
//#SH {$name1/etc.}
|
The above works. But curiously, uncomment the last #SH, and you get a parse error. A little experimentation shows that you can do:
Code: |
$name1/etc = "foo"
#SH {$name1/etc}
|
But in that case, "$name1/$name2" should have been looking for a "$name1/" variable. The docs don't specify the syntax of a local variable, but it would make sense to disallow most punctuation (other than "_") |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Sat Aug 02, 2008 10:31 pm |
As far as I can tell, the manual doesn't specify the syntax of specifying variables in other modules or packages...(!)
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sun Aug 03, 2008 5:19 pm |
That error does seem a bit odd. However, note that this works:
#SH {$name1"/etc."}
Yes, it seems to me that local variable names should not be able to contain slashes or certain other punctuation. |
|
|
|
Zhiroc Adept
Joined: 04 Feb 2005 Posts: 246
|
Posted: Wed Aug 13, 2008 3:58 am |
I think this behavior is a bug, so I'll bump it once, since it looks like it got buried :)
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Aug 13, 2008 4:53 pm |
I think it is just the / character that is causing the problem. It seems to be trying to parse the //module/class/var syntax for local variables, even though that doesn't really make any sense. I probably copied some code that was used for normal @var parsing and then didn't take out the handling of the / character properly.
Added to bug list. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Aug 13, 2008 10:33 pm |
I have removed the code that was handling the / character with a local variable reference. That seems to have fixed the problem and I haven't found any side effects.
When testing your procedure on the command line, I also ran across another bug. If you do this on the command line:
then notice the it displays "test" *with* the quotes! Side effect of something I added a few versions ago for the smart command line. This was also causing the same problem with local variable assignment on the command line. Anyway, I have also fixed this problem now. So in 2.36, the code:
Code: |
$name1 = "John"
$name2 = "Bill"
#SH {$name1/$name2}
#SH {$name1's}
#SH {$name1/etc.} |
now properly shows:
Code: |
Bill/John
Bill's
Bill/etc. |
|
|
|
|
|
|