Skip to content

New failure to parse in v0.15.0 #587

@wincent

Description

@wincent

I have some LuaJIT (ie. 5.1) source that parsed fine with v0.14.0:

vim.opt_local.include = [=[\v<((do|load)file|require)\s*\(?['"]\zs[^'"]+\ze['"]]=]

but with v0.15.0 I get a parse error:

error parsing: error occurred while tokenizing: unclosed string at line 2, column 25

So, it doesn't like the "long bracket" string — not sure if it's because of the quotes inside the string, or just long brackets in general, but it was and should be valid according to the Lua manual:

Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening square bracket followed by n equal signs followed by another opening square bracket. So, an opening long bracket of level 0 is written as [[, an opening long bracket of level 1 is written as [=[, and so on. A closing long bracket is defined similarly; for instance, a closing long bracket of level 4 is written as ]====]. A long string starts with an opening long bracket of any level and ends at the first closing long bracket of the same level. Literals in this bracketed form can run for several lines, do not interpret any escape sequences, and ignore long brackets of any other level. They can contain anything except a closing bracket of the proper level.

Workaround is to break the string over multiple lines:

vim.opt_local.include = vim.trim([[
  \v<((do|load)file|require)\s*\(?['"]\zs[^'"]+\ze['"]
]])

This might be similar to #585, and so probably needs to reported over in Kampfkarren/full-moon. I'll head over there now and do that, but I thought I'd report it here too for visibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalThis issue relies on an external factor

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions