luke-gru / riml

Riml is a subset of VimL with some nice added features. It compiles to plain VimL.
MIT License
224 stars 6 forks source link

Syntax error with dot access of "append" property on argument #18

Closed dsawardekar closed 10 years ago

dsawardekar commented 10 years ago

@luke-gru Does the word append have any special meaning within Riml? Here's an odd bug that reports a syntax error.

def change_destination(lines, range, opts)
  if opts.append
    append(line('$'), lines)
  else
    setline(1, lines)
  end
end

This code doesn't compile, the error suggests too many END statements, which is incorrect.

../riml-0.3.2/lib/lexer.rb:288:in `check_indentation': 1 too many END identifiers (Riml::SyntaxError)

Switching to an array access operator like opts['append'] works fine.

luke-gru commented 10 years ago

Thanks for the the report, this one was a good one :smile:

This bug was caused by a bad Regexp in the lexer for 'one line conditional' syntax, such as:

 if bar doBar() end

This used to be valid Riml syntax, and I forgot to take it out of the lexer :blush:

The bad Regexp wasn't checking for a word boundary before 'end', so if opts.append was being treated as one of these conditionals.

This is fixed and in master. Will be in new release tomorrow.

Thanks!

dsawardekar commented 10 years ago

Interesting. Thanks for the prompt fix!