Scripting Bugs

Things you’d like to miss in the future...
admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

Yep, fine new scripting bug! :tup:

Fix comes.

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Scripting Bugs

Post by PeterH »

admin wrote:Yep, fine new scripting bug! :tup:

Fix comes.
That's it: :bug: already is gone! :appl:

Thanks a lot! :beer:
W7(x64) SP1 German
( +WXP SP3 )

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

PeterH wrote:
PeterH wrote:ScriptStrictSyntay=1 :arrow: a small problem

I always use ScriptStrictSyntax=1 (Usually very helpful :-) )

Now, defining a User Defined Function, I forgot the starting {
=> no error shown.
But: the terminating } of an If inside of this function physically terminated the whole function body.

Like (just to demonstrate - $p may be 0, positive or other :biggrin: ):

Code: Select all

Function Func($p)   // here the missing {
 If ($p == 0) {
   text "hallo";
 }
// the previous } cuts off all of the following text!
// script works just up to this line.
 ElseIf ($p > 0) {
   text "Never executed...";
 }
 Else {
   text 'Else';
 }

 Text 'Never reached, too';
I'd say:
either the function should work without the embedding {} - as a normal script does,
or the missing { should be reported.
No :?:
This error is too complex for my modest homegrown parser. A minimum of user smartness is needed in scripting.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

TheQwerty wrote:Okay.. opinions on whether this is a bug or not:

Code: Select all

function test() {
  perm $value = rand(0,1000);
  echo "Test set value to $value";
}

test();echo "Script sees value of $value";
First execution main script does not find $value in scope. (Assuming you didn't have a $value PV which I just blew away for you. :twisted: )
On the second execution it will pick it up correctly.

In other words the calling script is not made aware of permanent variables created by functions.


This can be resolved by bringing the PV into scope before using it (before or after calling test() makes no difference) so it's no big deal, but may need pause for thought.
I think it is a bug. Well, I fixed it, so that kind of makes it a bug by reverse logic.

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Scripting Bugs

Post by PeterH »

admin wrote:This error is too complex for my modest homegrown parser. A minimum of user smartness is needed in scripting.
:oops:

OK: I don't plan to make the same mistake. But you never know :oops: :oops: :veryconfused:

Hm - is it really hard to test, that the first non-comment character after Function Func($p) is { :?:

(Yes: this doesn't test for the ending } - but that's a mistake I didn't make till now :biggrin: )
W7(x64) SP1 German
( +WXP SP3 )

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting Bugs

Post by bdeshi »

SC swapnames generates a success status message even if the operation failed (say, the items were UAC protected).
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

:bug: foreach aborts unexpectedly after handling a token containing an odd number of quotes:

Code: Select all

$test = 'a|b"c|d|e|f|g';
  $c = GetToken($test, 'Count', '|');
  $i = 0;
  foreach($line, $test) { $i++; }

  Echo "Iterated over $i lines.<crlf>Expected: $c";
Separator makes no difference - I ran into it parsing output from GetSectionList with its default CRLF.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting Bugs

Post by bdeshi »

TheQwerty wrote:an odd number of quotes:
Apparently only double-quotes.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Scripting Bugs

Post by PeterH »

Interesting to change the 1st line to
$test = 'a|b"c|d|e"|f|g'; :mrgreen:

For sure "foreach" should handle double-quotes as any other character.
(Like it does with single quotes, as Sammay said.)
W7(x64) SP1 German
( +WXP SP3 )

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

PeterH wrote:Interesting to change the 1st line to
$test = 'a|b"c|d|e"|f|g'; :mrgreen:

For sure "foreach" should handle double-quotes as any other character.
(Like it does with single quotes, as Sammay said.)
Indeed and this shows my description of the bug is incorrect.

Maybe.. foreach incorrectly prioritizes double-quotes over the specified separator causing unexpected behavior, especially when handling unmatched quotes.

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Scripting Bugs

Post by PeterH »

I think special handling of double-quotes *would* only make sense, if a pair of them *could* include separators. For me this *would* be the only reason for special handling. But I don't think this would make sense.

If it doesn't make sense, any double-quote should just be handled as any other character. (As is for single quotes.) And as such there's no difference if it's only one ore a pair of them.
W7(x64) SP1 German
( +WXP SP3 )

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting Bugs

Post by bdeshi »

PeterH wrote:I think special handling of double-quotes *would* only make sense, if a pair of them *could* include separators.
:veryconfused:
any double-quote should just be handled as any other character. (As is for single quotes.) And as such there's no difference if it's only one ore a pair of them.
Exactly. There shouldn't be absolutely any difference at all between single and double quotes, outside of (1) variable interpretation, and (2) escaped internal quoting, both cases just require looking at which quotes are enclosing the string.

There's something fishy about double-quotes handling. IIRC, there was another scrpting issue with double quotes very recently.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

PeterH wrote:I think special handling of double-quotes *would* only make sense, if a pair of them *could* include separators.
If what you're trying to get at is a way to escape the separator then I don't think quoting is a good method.

Though, I'm not sure there is a good solution either - at least not one which matches the flexibility of specifying the separator.

Doubling the separator would at least be consistent with quoting but the years have shown that to also be extremely confusing to most and it interferes with empty tokens.

Specifying a separate escape pattern could work but at that point we might as well just perform the escaping ourselves rather than have Don cram another argument into every function with a separator.
SammaySarkar wrote:There's something fishy about double-quotes handling. IIRC, there was another scrpting issue with double quotes very recently.
I had the same feeling but the only issue coming to mind was klownboy's quoted-separators become gotos issue which was apparently introduced after 16.40. This bug however appears in that version as well so it's unlikely to be related. (Plus multiple people can recreate this one. ;))

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Scripting Bugs

Post by PeterH »

...but I hope you both didn't get me wrong - I said:
PeterH wrote:But I don't think this would make sense.
So it seems we all think that a double-quote should be handled here as any other character.
W7(x64) SP1 German
( +WXP SP3 )

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

SammaySarkar wrote:SC swapnames generates a success status message even if the operation failed (say, the items were UAC protected).
Thanks. Same bug in File | File Special | Swap Names.

Post Reply