[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

small question about ruby -c

pat eyler

12/7/2005 4:05:00 PM

interesting little bug (I think)

When generating the answer to a previous email, I ran ruby -c against
a script and got 'syntax ok'. (as expected) I then changed an
if/else/end to if/otherwise/end, ran ruby -c again, and got 'syntax
ok'. (not as expected). I went ahead and ran the script (with the
'otherwise' change) and got:

-- primes_with_error.rb:29: undefined local variable or method
`otherwise' for main:Object (NameError)
from primes_with_error.rb:25:in `each'
from primes_with_error.rb:25


Any reason that ruby -c didn't catch this?


thanks,
-pate
-------------------------


13 Answers

Patrick Hurley

12/7/2005 4:12:00 PM

0

On 12/7/05, pat eyler <pat.eyler@gmail.com> wrote:
> When generating the answer to a previous email, I ran ruby -c against
> a script and got 'syntax ok'. (as expected) I then changed an
> if/else/end to if/otherwise/end, ran ruby -c again, and got 'syntax
> ok'. (not as expected).

I can't see your code, but my guess is that the ruby interpreter
figured that otherwise is a function (not an accidental name for
else), so it is good syntax, even though there is a runtime error for
the missing method/variable name.

pth


Pit Capitain

12/7/2005 4:14:00 PM

0

pat eyler schrieb:
> interesting little bug (I think)
>
> When generating the answer to a previous email, I ran ruby -c against
> a script and got 'syntax ok'. (as expected) I then changed an
> if/else/end to if/otherwise/end, ran ruby -c again, and got 'syntax
> ok'. (not as expected). I went ahead and ran the script (with the
> 'otherwise' change) and got:
>
> -- primes_with_error.rb:29: undefined local variable or method
> `otherwise' for main:Object (NameError)
> from primes_with_error.rb:25:in `each'
> from primes_with_error.rb:25
>
> Any reason that ruby -c didn't catch this?

Pat, this isn't a syntax error. The *syntax* is correct. Just define a
method or local variable named "otherwise" and all is fine.

Regards,
Pit


MenTaLguY

12/7/2005 5:52:00 PM

0

Quoting pat eyler <pat.eyler@gmail.com>:

> ok'. (not as expected). I went ahead and ran the script (with
> the 'otherwise' change) and got:
>
> -- primes_with_error.rb:29: undefined local variable or method
> `otherwise' for main:Object (NameError)
> from primes_with_error.rb:25:in `each'
> from primes_with_error.rb:25
>
>
> Any reason that ruby -c didn't catch this?

Basically, it's not a syntax error. It's possible for a script to
be wrong in surprising ways but still syntactically valid.

-mental


Man of Mind

10/30/2010 6:02:00 PM

0

On 10/30/2010 11:34 AM, Gorged Simpleton whimpered the usual:
>
> Must be that you leftists just like to invent things to whine about,

Nope, That would be you 'frightie-righties'..

--As you desperately cling to a failed political ideology..

George Plimpton

10/30/2010 6:15:00 PM

0

On 10/30/2010 11:01 AM, Mindless *fake* "man" Kurtsie Loopner lied:
> On 10/30/2010 11:34 AM, Sir George Plimpton (KBE) instructed:
>>
>> Must be that you leftists just like to invent things to whine about,
>
> Nope, That would

Yep, Kurtsie - you leftists invent shit to whine about. Leftist =
whiner (in addition, of course, to leftist = racist)


--
....and that's just how it is.

Man of Mind

10/30/2010 9:09:00 PM

0

On 10/30/2010 1:14 PM, Bored Simpleton whimpered the usual:
>
> On 10/30/2010 11:01 AM, Man_of_mind excoriated the ambitious ignorance of:
>>
>> On 10/30/2010 11:34 AM, Bored Simpleton was sniveling like a tard:
>>>
>>> Must be that you leftists just like to invent things to whine about,
>>
>> Nope, That would be you 'frightie-righties'..
>>
>> --As you desperately cling to a failed political ideology..
>
> Yep

So, own up to it, admit the right-wing is wrong..

--Grow a pair, or quit your 'adolescent bitching', simpleton..

George Plimpton

10/30/2010 9:30:00 PM

0

Kurtsie Loopner blabbered:
>[bullshit]

You really blow, Kurtsie.

--
....and that's just how it is.

Phlip

10/30/2010 9:46:00 PM

0

On Oct 30, 2:29 pm, George Plimpton <geo...@si.not> wrote:
> Kurtsie Loopner blabbered:
>
> >[bullshit]
>
> You really blow, Kurtsie.

A Dem ad on YouTube, featuring one of Rand Paul's close personal
friends stomping on a journalist's head, has over 60k views and
counting.

Oh, and Obama foiled a big terror attack.

Whine all you want, Pimples, your side is going down.

Man of Mind

10/30/2010 9:48:00 PM

0

On 10/30/2010 4:29 PM, Bored Simpleton whimpered, deleted/bleated:
>
> Man_of_Mind easily out-witted the malignant narcissist, known as:
>>
>> On 10/30/2010 1:14 PM, Bored Simpleton whimpered the usual:
>>>
>>> On 10/30/2010 11:01 AM, Man_of_mind excoriated the ambitious ignorance of:
>>>>
>>>> On 10/30/2010 11:34 AM, Bored Simpleton was sniveling like a tard:
>>>>>
>>>>> Must be that you leftists just like to invent things to whine about,
>>>>
>>>> Nope, That would be you 'frightie-righties'..
>>>>
>>>> --As you desperately cling to a failed political ideology..
>>>
>>> Yep
>>
>> So, own up to it, admit the right-wing is wrong..
>>
>> --Grow a pair, or quit your 'adolescent bitching', simpleton..
>
> You really blow

Nah, it just sucks to be you..

--See subject header for details..

George Plimpton

10/30/2010 9:55:00 PM

0

On 10/30/2010 2:45 PM, Phlip wrote:
> On Oct 30, 2:29 pm, George Plimpton<geo...@si.not> wrote:
>> Kurtsie Loopner blabbered:
>>
>>> [bullshit]
>>
>> You really blow, Kurtsie.
>
> A Dem ad on YouTube, featuring one of Rand Paul's close personal
> friends stomping on a journalist's head, has over 60k views and
> counting.

Excellent. Did they fracture his skull, I hope?


--
....and that's just how it is.