rouge icon indicating copy to clipboard operation
rouge copied to clipboard

Closing bracket highlighted in red if block has more than 5 arguments

Open Sayrus opened this issue 1 year ago • 1 comments

Name of the lexer When a block has more than 5 arguments, the closing bracket is highlighted in red.

Code sample A sample of the code that produces the bug.

block {
  a = true
  b = true
  c = true
  d = true
  e = true
  f = true
}

block {
  a = true
  b = true
  c = true
  d = true
  e = true
}

resource "test" "test" {
  a = true
  b = true
  c = true
  d = true
  e = true
  f = true
}

https://rouge.jneen.net/v4.5.1/terraform/YmxvY2sgewogIGEgPSB0cnVlCiAgYiA9IHRydWUKICBjID0gdHJ1ZQogIGQgPSB0cnVlCiAgZSA9IHRydWUKICBmID0gdHJ1ZQp9CgpibG9jayB7CiAgYSA9IHRydWUKICBiID0gdHJ1ZQogIGMgPSB0cnVlCiAgZCA9IHRydWUKICBlID0gdHJ1ZQp9CgpyZXNvdXJjZSAidGVzdCIgInRlc3QiIHsKICBhID0gdHJ1ZQogIGIgPSB0cnVlCiAgYyA9IHRydWUKICBkID0gdHJ1ZQogIGUgPSB0cnVlCiAgZiA9IHRydWUKfQ

image

Additional context N/A

Sayrus avatar Dec 19 '24 10:12 Sayrus

  trying: #<Rule //>
    got: ""
    yielding: Text, ""
    popping stack: 1
    warning: too many scans without consuming the string!
    no match, yielding Error

The reason is that it recurse inside :composite for each additional property. Leading to the scanner reach }\n and popping all the :composite.

Stack before popping them:

stack: [:root, :hash, :composite, :composite, :composite, :composite, :composite, :composite]

The reason why it fails after that is because MAX_NULL_SCANS = 5. So the number of arguments is limited by the stack it reaches why recursing into :composite.

Sayrus avatar Dec 19 '24 10:12 Sayrus