Hmmm - no compilation error ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Hmmm - no compilation error ?

Geoff Canyon via use-livecode
I accidentally typed the equivalent of

function x p
    return return p
end x

i.e. I had the word "return" in there twice.

And it didn't give me an error on compilation, and also didn't just
ignore the repeated word, it simply returned a blank line.

Does it seem like this is a bug ?  Is the parser too lenient ?

(LC 9.0.0, and 8.1.5 tested)


Ohhhh - and while testing it out for this email, I tried to type

ask "a" & x(3) & "b"

but instead I did

ask "a"  x(3) & "b"
(i.e. missing an '&')

and that too didn't give an error; it simply ignored the extra part of
the line. !?

Thanks

Alex.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Hmmm - no compilation error ?

Geoff Canyon via use-livecode
The parser is often lenient at the end of statements like this.

In the case of the return statement it first looks for the expression to return then checks if the next token is either `for` or `with`. If it isn’t either of those it doesn’t look any further or throw an error.

Really we should have a general check for extra stuff after parsing statements but we don’t. Stuff like that can also be a bit risky to add as all of a sudden a lot of scripts that work perfectly well might not compile.

Cheers

Monte

> On 30 Oct 2018, at 12:00 pm, Alex Tweedly via use-livecode <[hidden email]> wrote:
>
> I accidentally typed the equivalent of
>
> function x p
>    return return p
> end x
>
> i.e. I had the word "return" in there twice.
>
> And it didn't give me an error on compilation, and also didn't just ignore the repeated word, it simply returned a blank line.
>
> Does it seem like this is a bug ?  Is the parser too lenient ?
>
> (LC 9.0.0, and 8.1.5 tested)
>
>
> Ohhhh - and while testing it out for this email, I tried to type
>
> ask "a" & x(3) & "b"
>
> but instead I did
>
> ask "a"  x(3) & "b"
> (i.e. missing an '&')
>
> and that too didn't give an error; it simply ignored the extra part of the line. !?
>
> Thanks
>
> Alex.
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Hmmm - no compilation error ?

Geoff Canyon via use-livecode
Yeah, IMHO it's academic, as the point to a compiler syntax checker is to avoid runtime errors down the road. Since this will not throw a runtime error, it's moot.

Bob S


> On Oct 29, 2018, at 19:27 , Monte Goulding via use-livecode <[hidden email]> wrote:
>
> The parser is often lenient at the end of statements like this.
>
> In the case of the return statement it first looks for the expression to return then checks if the next token is either `for` or `with`. If it isn’t either of those it doesn’t look any further or throw an error.
>
> Really we should have a general check for extra stuff after parsing statements but we don’t. Stuff like that can also be a bit risky to add as all of a sudden a lot of scripts that work perfectly well might not compile.
>
> Cheers
>
> Monte
>
>> On 30 Oct 2018, at 12:00 pm, Alex Tweedly via use-livecode <[hidden email]> wrote:
>>
>> I accidentally typed the equivalent of
>>
>> function x p
>>   return return p
>> end x
>>
>> i.e. I had the word "return" in there twice.
>>
>> And it didn't give me an error on compilation, and also didn't just ignore the repeated word, it simply returned a blank line.
>>
>> Does it seem like this is a bug ?  Is the parser too lenient ?
>>
>> (LC 9.0.0, and 8.1.5 tested)
>>
>>
>> Ohhhh - and while testing it out for this email, I tried to type
>>
>> ask "a" & x(3) & "b"
>>
>> but instead I did
>>
>> ask "a"  x(3) & "b"
>> (i.e. missing an '&')
>>
>> and that too didn't give an error; it simply ignored the extra part of the line. !?
>>
>> Thanks
>>
>> Alex.
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode