Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested positive lookaheads consume characters #2918

Closed
Thom1729 opened this issue Aug 5, 2019 · 1 comment
Closed

Nested positive lookaheads consume characters #2918

Thom1729 opened this issue Aug 5, 2019 · 1 comment

Comments

@Thom1729
Copy link

Thom1729 commented Aug 5, 2019

@deathaxe noticed a bug with nested lookaheads in sublimehq/Packages#2044. I think I've nailed down the problem.

Description

When the last character examined by the expression is inside multiple nested lookaheads, the engine only “unwinds” the innermost lookahead before marking the end of the match.

The bug occurs for rules with push, but not for rules that don't use the stack. (I haven't tested set, pop, or embed.)

Steps to reproduce

Use the following syntax definition:

%YAML 1.2
---
name: Nested lookahead test
scope: source.nested-lookahead-test
contexts:
  main:
    - match: (?=A)
      scope: region.greenish
      push: pop-at-eol
    - match: (?=B(?=1))
      scope: region.greenish
      push: pop-at-eol
    - match: (?=C(?=1(?=2)))
      scope: region.greenish
      push: pop-at-eol
    - match: (?=D(?=1(?=2(?=3))))
      scope: region.greenish
      push: pop-at-eol
    - match: (?=E(?=1(?=2(?=3))))\b
      scope: region.greenish
      push: pop-at-eol
    - match: (?=F(?=1(?=2(?=3))))(?=F)
      scope: region.greenish
      push: pop-at-eol
    - match: (?=G(?=1(?=2(?=3))))(?=G(?=1))
      scope: region.greenish
      push: pop-at-eol

  pop-at-eol:
    - match: $
      pop: true

And the following test file:

A
B1
C12
D123
E123
F123
G123

Expected behavior

No characters in the test file should be green because every rule matches zero characters.

Actual behavior

Many characters are green.

Environment

  • Build: 3208
  • Mac OS 10.14.6
@wbond
Copy link
Member

wbond commented Jul 10, 2020

This was fixed in build 4075

@wbond wbond closed this as completed Jul 10, 2020
@wbond wbond added this to the Build 4075 milestone Jul 10, 2020
@wbond wbond added the R: fixed label Jul 10, 2020
@wbond wbond removed their assignment Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants