Skip to content

JavaScript in the fancy-regex syntax set never finishes on a two-line input #166

Closed as not planned

Description

@oetiker

With two-face 0.5.2+bat-0.26.1 (syntect-fancy) and syntect 5.3.0, the syntax named
JavaScript in the fancy set does not return from ParseState::parse_line on this input:

  | { type: "a" }
  /** x */

The second line runs for minutes at flat memory. An onig-linked syntect build, with the
syntax selected by name, hangs the same way, so the cause is in the definition, not in the
regex engine.

Cause: expression-statement-continuation matches empty (the / of /* is in its operator
class), and the "rest of the line is blanks and comments" rule also matches empty; the two
set each other forever. syntect's loop guard only catches non-consuming pushes
(trishume/syntect#706 diagnoses this; #460 is the older report).

sublimehq/Packages fixed the definition in #3257 (2022-11), but that fix uses branch_point,
which syntect 5.3.0 cannot load. bat avoids the hang by mapping js to JavaScript (Babel),
which the fancy set excludes. So a fancy-set user who resolves js by token gets the
looping definition.

Possible ways out, your call: note it in the README's fancy-set legend, or ship a patched
JavaScript in the fancy set that drops the empty match.

Found in mdmost (https://github.com/oetiker/mdmost), which now guards against it with a
per-line token limit in a vendored syntect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions