Scripting Bugs

Things you’d like to miss in the future...
PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Scripting Bugs

Post by PeterH »

Filehero wrote:Should the message really pop up?
For me it says "Dubious syntax" :whistle:

In such a situation XY often finds "some solution". Even if you don't like it :mrgreen:
As I don't like it I use Syntax Check :tup:
W7(x64) SP1 German
( +WXP SP3 )

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Scripting Bugs

Post by Filehero »

PeterH wrote:In such a situation XY often finds "some solution".
It shouldn't because broken code not only doesn't screem, it is silently inverting the logical flow intended.

But I know you don't like it as well. :biggrin:

Thanks PeterH.

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Scripting Bugs

Post by Filehero »

Ok, it also cheats the other direction

Code: Select all

                               v <-- missing closing bracket
  if (exists("C:\windows" == 1) {
    msg("Wouw, system root is a file!");
  }
Master of puppets (1986): The Thing That Should Not Be

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

Re: Scripting Bugs

Post by admin »

If the parentheses don't match both cases are interpreted as a literal string which in the context evaluates as true. It is as if you did:

Code: Select all

  if "(1 == 2))" {
    msg("Wouw, Math revolution!");
  }

Code: Select all

  if "((1 == 2)" {
    msg("Wouw, Math revolution!");
  }
Syntax Checking detects both cases.

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Scripting Bugs

Post by Filehero »

Ok, thanks.

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

Re: Scripting Bugs

Post by PeterH »

I just want to add a word :maf:

These examples were examples of illegal syntax!
What Don explained was XY's current reaction on this kind of illegal syntax - it was not a part of real syntax description. (Note Don's words "as if you did"! But you didn't!)

To avoid those situations: switch "Syntax Checking" to "On" - then XY will notify you about syntax errors you made - and you will be noticed about your error, and not be surprised by some "as if".

I'll never understand why this isn't XY's default, so that anyone not wanting his code to be checked (= verified) for syntax errors has to define this explicitely, and on his own risk.
W7(x64) SP1 German
( +WXP SP3 )

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Scripting Bugs

Post by highend »

I'm my own syntax checker. I make errors on purpose! :appl:
One of my scripts helped you out? Please donate via Paypal

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Scripting Bugs

Post by Filehero »

PeterH wrote:I'll never understand why this isn't XY's default, so that anyone not wanting his code to be checked (= verified) for syntax errors has to define this explicitely, and on his own risk.
That describes my original confusion perfectly. I simply had expected a runtime error by the script interpreter, which is what the syntax checker does in this case, right?

Lesson learned, from now on I will leave it always active (thanks for reminding me of the obvious :oops: ).

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

Re: Scripting Bugs

Post by admin »

10 minutes ago I made it the factory default. :)

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

Re: Scripting Bugs

Post by PeterH »

admin wrote:10 minutes ago I made it the factory default. :)
:appl: :appl: :appl:

But I'm afraid you should give clear info for those that made them selves dependent on illegal syntax :ghost:
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 »

Radical #Nowdoc breaks block comment parsing.

Code: Select all

"test 1"
  /* comment before radical nowdoc is okay */
  $data_matrix = <<<'#>>>'
      $G_SELECTIONS_PATHKEY  | $G_SELECTIONS_DIRP |
      $G_SELECTIONS_NAMEDKEY | $G_SELECTIONS_DIRN | *#>>>;
  text $data_matrix;

/* block comments AFTER radical newdoc is broken */

Code: Select all

"test 2"
  /* comment before radical nowdoc is okay */
  $data_matrix = <<<'#>>>'
      $G_SELECTIONS_PATHKEY  | $G_SELECTIONS_DIRP |
      $G_SELECTIONS_NAMEDKEY | $G_SELECTIONS_DIRN | *#>>>;
  text $data_matrix;
  /* INDENTED block comments are broken differently */

Code: Select all

/* note, $data_matrix [...] starts indented */
  $data_matrix = <<<'#>>>'
      $G_SELECTIONS_PATHKEY  | $G_SELECTIONS_DIRP |
      $G_SELECTIONS_NAMEDKEY | $G_SELECTIONS_DIRN | *#>>>;
  text $data_matrix;
/* block comments AFTER radical newdoc is broken */
  /* INDENTED block comments are broken differently */
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 »

Maybe the <<<'#>>>' should just be <<<#>>> :?:

I remember that after problems with heredoc I often saw very very strange results later on.
W7(x64) SP1 German
( +WXP SP3 )

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Scripting Bugs

Post by highend »

Then it would be a #Heredoc :ninja:
One of my scripts helped you out? Please donate via Paypal

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

Re: Scripting Bugs

Post by PeterH »

I'm not sure what Sammay wanted to achive with the expression <<<'#>>>' - for me the quotes look/seem a bit as if he wanted to quote the heredoc (end-)identifier. (I never would have the idea of using quotes here.) If it's so the # would mean "radical heredoc parsing". (I love to use it!) If not, then the # would be a char inside the identifier - I never would do that, too.

In the end *my* personal advices:
- don't use quotes in heredoc-id
- only start heredoc-id by # if you really want radical parsing
- don't use # inside heredoc-id

Maybe Don can clearify these statements.

I think saying "#Heredoc" highend wanted to give a hint to the "radical parsing" characteristic, if id starts with #.

By the way: I usually use <<<#>>> for heredocs. I think it's rather good to recognize.

Peter

edit: addon to "*my* personal advices"
My co-workers always said:
Nicht denken - sauber bleiben! :arrow:
Don't think - keep clean!

I think this can be helpful :D
W7(x64) SP1 German
( +WXP SP3 )

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Scripting Bugs

Post by highend »

@PeterH

No, you're misunderstanding the whole thing. Sorry!

Sammay is explicitly talking about #Nowdocs and these
require a single quoted identifier. In this case the

Code: Select all

'#>>>'
I think saying "#Heredoc" highend wanted to give a hint to the "radical parsing" characteristic, if id starts with #.
No, I wanted to give you a hint, that with your comment:

Code: Select all

Maybe the <<<'#>>>' should just be <<<#>>>
his #Nowdocs would transform into a #Heredocs and #Heredocs don't suffer
from the same problem :mrgreen:
One of my scripts helped you out? Please donate via Paypal

Post Reply