Oldes / Rebol-wishes

Repository for keeping Rebol related wishes out of issues
0 stars 0 forks source link

Legality of QUOTE in PARSE for String Series (=> Illegal?) #6

Open Siskin-Bot opened 4 years ago

Siskin-Bot commented 4 years ago

Submitted by: Hostilefork

The following code doesn't (always) crash in R3-Alpha:

>> parse "" [quote ()]
== false

However, what it is doing is accessing the string input as if it were an "any block" (a.k.a. ARRAY) for a comparison, which is an invalid interpretation of the bits:

https://github.com/rebol/rebol/blob/25033f897b2bd466068d7663563cd3ff64740b94/src/core/u-parse.c#L899

That's a bug (Ren-C is noisy enough to notice, R3-Alpha isn't and just maybe crashes, maybe returns false). But what is the desired behavior? Note that it is illegal to use other arbitrary values as source for a parse rule:

>> parse "a" ['a]      
** Script error: PARSE - invalid rule or usage of rule: 'a
** Where: parse
** Near: parse "a" ['a]

This should give the same output:

>> parse "a" [quote a]

And so should this:

>> parse "a" [quote ('a)]

Other operations that are not designed for use on string series avoid such behavior by checking first to make sure the input is not a string, and if it is jump to bad_rule:

https://github.com/rebol/rebol/blob/25033f897b2bd466068d7663563cd3ff64740b94/src/core/u-parse.c#L915

That's an easy fix for this case, but it rules out the ability to quote strings, which one might imagine being legal.

For the moment Ren-C disallows QUOTE when the input is a string series.


Imported from: https://github.com/rebol/rebol-issues/issues/2253

Comments:


Hostilefork mentioned this issue on Jan 14, 2016: parse "" [quote ()]


Ladislav added Type.note, Type.bug, Type.wish on Feb 7, 2016