hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.84k stars 448 forks source link

Typo in Tokenizer code? #2709

Open rirze opened 1 year ago

rirze commented 1 year ago

Community Note

Affected Resource(s)

On line 135 in cdktf/lib/private/tokens/encoding.ts:

if (startMatch && endMatch) {
      if (startMatch.index > startIndex && startMatch.index > startIndex) {  // this conditional is repeated?
        const lede = this.str.substring(
          startIndex,
          Math.min(startMatch.index, endMatch.index)
        );
        fragments.addLiteral(lede);
      }

In the second line, the if statement has the same conditional repeated. Is this intentional-- am I missing some crucial TS knowledge?

If I had to guess what the second conditional would be, then I would guess endMatch.index > startIndex. But I'm not so confident in the logic here to definitively open that PR.

DanielMSchmidt commented 1 year ago

Yeah, that really looks like a typo. Maybe we can do some archeology to see if there was something correct before 🤔

ansgarm commented 1 year ago

Or someone wanted to be really sure 😂