Missing "end" and My least favourite ruby error message....

Discussion in 'Ruby' started by John Carter, Sep 5, 2007.

  1. John Carter

    John Carter Guest

    "syntax error, unexpected $end, expecting kEND"

    With the line number pointing to the last line of the file.

    So I was busy doing something when I was interrupted and I dropped an
    "end" somewhere.

    No idea where.

    Sigh! Time for a binary chop search.

    I wish I could think of an easier way, like the highlighting emacs
    does for '(; and '{'





    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand
    John Carter, Sep 5, 2007
    #1
    1. Advertising

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    John Carter wrote:
    > "syntax error, unexpected $end, expecting kEND"
    >
    > With the line number pointing to the last line of the file.
    >
    > So I was busy doing something when I was interrupted and I dropped an
    > "end" somewhere.
    >
    > No idea where.
    >
    > Sigh! Time for a binary chop search.
    >
    > I wish I could think of an easier way, like the highlighting emacs
    > does for '(; and '{'
    >
    >
    >
    >
    >
    > John Carter Phone : (64)(3) 358 6639
    > Tait Electronics Fax : (64)(3) 359 4632
    > PO Box 1645 Christchurch Email :
    > New Zealand
    >
    >
    >


    I think vim syntax coloring highlights xx-end pairs, and Komodo's
    auto-indent cleans them up nicely as well.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFG3yxa8fKMegVjSM8RAr13AKCMwMxxNxYp/bbQH7reUZG2ey00nQCgx3p2
    yOIZh817XZU1pc8B3Xbaa7k=
    =8AgP
    -----END PGP SIGNATURE-----
    M. Edward (Ed) Borasky, Sep 5, 2007
    #2
    1. Advertising

  3. Hi,

    Am Donnerstag, 06. Sep 2007, 07:23:36 +0900 schrieb M. Edward (Ed) Borasky:
    > John Carter wrote:
    > > "syntax error, unexpected $end, expecting kEND"
    > >
    > > With the line number pointing to the last line of the file.
    > >
    > > So I was busy doing something when I was interrupted and I dropped an
    > > "end" somewhere.
    > >
    > > I wish I could think of an easier way, like the highlighting emacs
    > > does for '(; and '{'

    >
    > I think vim syntax coloring highlights xx-end pairs, and Komodo's
    > auto-indent cleans them up nicely as well.


    The newest Vim highlights module's `end' underlined and
    classes `end' non-underlined. Moving the module's end
    through the file I find them quite easy.

    The only thing I have to do is to update my old
    sub-highlighting that features SQL and TeX strings. Sigh.

    Bertram


    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
    Bertram Scharpf, Sep 5, 2007
    #3
  4. On 9/5/07, Bertram Scharpf <> wrote:
    > Hi,
    >
    > Am Donnerstag, 06. Sep 2007, 07:23:36 +0900 schrieb M. Edward (Ed) Borasky:
    > > John Carter wrote:
    > > > "syntax error, unexpected $end, expecting kEND"
    > > >
    > > > With the line number pointing to the last line of the file.


    > > > I wish I could think of an easier way, like the highlighting emacs
    > > > does for '(; and '{'

    > >
    > > I think vim syntax coloring highlights xx-end pairs,


    I find that the best way to find these in (g)vim is

    ggVG=

    ggVG selects all the lines in the file and then = re-formats the indentation.

    In most cases this will point out the problem, although there are a
    few cases where vims ruby formatter got confused.

    I had one today which had me scratching my head for a few moments, I'd
    inadvertantly put in a line something like

    x .y unless unless a.b

    Took me a bit of effort to find that one.

    --
    Rick DeNatale

    My blog on Ruby
    http://talklikeaduck.denhaven2.com/
    Rick DeNatale, Sep 6, 2007
    #4
  5. On 9/6/07, Rick DeNatale <> wrote:
    > On 9/5/07, Bertram Scharpf <> wrote:
    > > Hi,
    > >
    > > Am Donnerstag, 06. Sep 2007, 07:23:36 +0900 schrieb M. Edward (Ed) Borasky:
    > > > John Carter wrote:
    > > > > "syntax error, unexpected $end, expecting kEND"
    > > > >
    > > > > With the line number pointing to the last line of the file.

    >
    > > > > I wish I could think of an easier way, like the highlighting emacs
    > > > > does for '(; and '{'
    > > >
    > > > I think vim syntax coloring highlights xx-end pairs,

    >
    > I find that the best way to find these in (g)vim is
    >
    > ggVG=
    >
    > ggVG selects all the lines in the file and then = re-formats the indentation.


    gg=G
    move to start of file, initiate indent-action, move to end of file :)

    and yeah, that's how i find 99.5% of missing ends, unless i use some
    regexps that mess up the indentation :|

    ^ manveru
    Michael Fellinger, Sep 6, 2007
    #5
  6. John Carter

    John Carter Guest

    On Thu, 6 Sep 2007, John Carter wrote:

    > "syntax error, unexpected $end, expecting kEND"
    >
    > With the line number pointing to the last line of the file.
    >
    > So I was busy doing something when I was interrupted and I dropped an
    > "end" somewhere.
    >
    > No idea where.
    >
    > Sigh! Time for a binary chop search.
    >
    > I wish I could think of an easier way, like the highlighting emacs
    > does for '(; and '{'


    Binary chop was useless. Wherever I put an "end", it would compile!

    It took me ages to review it line by line and spot it....

    blah.each do |line|
    foo.bah( line)
    foo.blech
    foo.
    end

    Ruby helpfully thought I was invoking the "end" method on the object in the foo variable.

    Sigh!

    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand
    John Carter, Sep 6, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Philipp Gressly
    Replies:
    5
    Views:
    755
    Knute Johnson
    Apr 17, 2005
  2. Andy Dingley

    Menu bar - that old favourite

    Andy Dingley, Jul 27, 2005, in forum: HTML
    Replies:
    3
    Views:
    539
  3. Alex Hunsley
    Replies:
    0
    Views:
    376
    Alex Hunsley
    May 3, 2006
  4. AAaron123
    Replies:
    0
    Views:
    591
    AAaron123
    Oct 3, 2008
  5. Dominic
    Replies:
    2
    Views:
    289
    Gunnar Peipman
    Dec 26, 2004
Loading...

Share This Page