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

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

Open
Sayrus opened this issue Dec 19, 2024 · 1 comment
Open
Labels
bugfix-request A request for a bugfix to be developed.

Comments

@Sayrus
Copy link

Sayrus commented Dec 19, 2024

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 Sayrus added the bugfix-request A request for a bugfix to be developed. label Dec 19, 2024
@Sayrus
Copy link
Author

Sayrus commented Dec 19, 2024

  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix-request A request for a bugfix to be developed.
Projects
None yet
Development

No branches or pull requests

1 participant