Skip to content

Leaking BeginEndRules for the following snippet #252

Closed

Description

Extracted from microsoft/vscode#10567

function getPage(p, base) {
    if (filename == base + "index") { var route = "/" + base }
}

At the end of the file, there should be a single rule on the stack, but there are 3.

Full analysis:


> [email protected] inspect c:\Alex\src\vscode-textmate
> node scripts/inspect.js "..\vscode\extensions\javascript\syntaxes\JavaScript.tmLanguage.json" "..\working_dir\10567\test.js"



===========================================
TOKENIZING LINE 1
function getPage(p, base) {

  LINE CONTAINS 11 TOKENS:
    => TOKEN (0-8): 
      function
      * source.js
      * meta.function.js
      * storage.type.function.js
    => TOKEN (8-9): 

      * source.js
      * meta.function.js
    => TOKEN (9-16): 
      getPage
      * source.js
      * meta.function.js
      * entity.name.function.js
    => TOKEN (16-17): 
      (
      * source.js
      * meta.function.js
      * meta.function.type.parameter.js
      * meta.brace.round.js
    => TOKEN (17-18): 
      p
      * source.js
      * meta.function.js
      * meta.function.type.parameter.js
      * parameter.name.js
      * variable.parameter.js
    => TOKEN (18-19): 
      ,
      * source.js
      * meta.function.js
      * meta.function.type.parameter.js
    => TOKEN (19-20): 

      * source.js
      * meta.function.js
      * meta.function.type.parameter.js
      * parameter.name.js
    => TOKEN (20-24): 
      base
      * source.js
      * meta.function.js
      * meta.function.type.parameter.js
      * parameter.name.js
      * variable.parameter.js
    => TOKEN (24-25): 
      )
      * source.js
      * meta.function.js
      * meta.function.type.parameter.js
      * meta.brace.round.js
    => TOKEN (25-26): 

      * source.js
      * meta.function.js
    => TOKEN (26-27): 
      {
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.brace.curly.js

  LINE END RULE STACK CONTAINS 3 RULES:
      * [136,1] BeginEndRule "meta.decl.block.js", entered @25
      * [153,2] BeginEndRule "meta.function.js", entered @0
      * [1,3] IncludeOnlyRule "source.js", entered @-1


===========================================
TOKENIZING LINE 2
    if (filename == base + "index") { var route = "/" + base }

  LINE CONTAINS 27 TOKENS:
    => TOKEN (0-1): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
    => TOKEN (1-3): 
      if
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * keyword.control.js
    => TOKEN (3-4): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
    => TOKEN (4-5): 
      (
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.brace.paren.js
    => TOKEN (5-14): 
      filename 
      * source.js
      * meta.function.js
      * meta.decl.block.js
    => TOKEN (14-16): 
      ==
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * keyword.operator.comparison.js
    => TOKEN (16-22): 
       base 
      * source.js
      * meta.function.js
      * meta.decl.block.js
    => TOKEN (22-23): 
      +
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * keyword.operator.arithmetic.js
    => TOKEN (23-24): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
    => TOKEN (24-25): 
      "
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * string.double.js
    => TOKEN (25-30): 
      index
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * string.double.js
    => TOKEN (30-31): 
      "
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * string.double.js
    => TOKEN (31-32): 
      )
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.brace.paren.js
    => TOKEN (32-33): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
    => TOKEN (33-34): 
      {
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.brace.curly.js
    => TOKEN (34-35): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
    => TOKEN (35-38): 
      var
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * storage.type.js
    => TOKEN (38-39): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
    => TOKEN (39-44): 
      route
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
      * variable.js
    => TOKEN (44-46): 
       =
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
    => TOKEN (46-47): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
    => TOKEN (47-48): 
      "
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
      * string.double.js
    => TOKEN (48-49): 
      /
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
      * string.double.js
    => TOKEN (49-50): 
      "
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
      * string.double.js
    => TOKEN (50-51): 

      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
    => TOKEN (51-52): 
      +
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js
      * keyword.operator.arithmetic.js
    => TOKEN (52-59): 
       base }
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.var.expr.js
      * meta.var-single-variable.expr.js

  LINE END RULE STACK CONTAINS 4 RULES:
      * [195,4] BeginEndRule "meta.block.js", entered @32
      * [136,1] BeginEndRule "meta.decl.block.js", entered @-1
      * [153,2] BeginEndRule "meta.function.js", entered @-1
      * [1,3] IncludeOnlyRule "source.js", entered @-1


===========================================
TOKENIZING LINE 3
}

  LINE CONTAINS 1 TOKENS:
    => TOKEN (0-1): 
      }
      * source.js
      * meta.function.js
      * meta.decl.block.js
      * meta.block.js
      * meta.brace.curly.js

  LINE END RULE STACK CONTAINS 3 RULES:
      * [136,1] BeginEndRule "meta.decl.block.js", entered @-1
      * [153,2] BeginEndRule "meta.function.js", entered @-1
      * [1,3] IncludeOnlyRule "source.js", entered @-1


===========================================
TOKENIZING LINE 4


  LINE CONTAINS 1 TOKENS:
    => TOKEN (0-1): 

      * source.js
      * meta.function.js
      * meta.decl.block.js

  LINE END RULE STACK CONTAINS 3 RULES:
      * [136,1] BeginEndRule "meta.decl.block.js", entered @-1
      * [153,2] BeginEndRule "meta.function.js", entered @-1
      * [1,3] IncludeOnlyRule "source.js", entered @-1

Activity

  1. mhegazy commented on Aug 29, 2016

    @mhegazy
    Contributor

    Sheetal Nandi (@sheetalkamat) is looking at rewriting this file right now. Sheetal Nandi (@sheetalkamat) can you take a look at this issue and see if it still reproduces on your new version.

  2. added a commit that references this issue on Sep 7, 2016
    21d57cb
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions