Skip to content

Conversation

@gavin-ts
Copy link
Contributor

@gavin-ts gavin-ts commented Oct 5, 2023

Summary

Fixes a panic that could happen using a var in a glob.

Details

  • fixes panic using var in glob #1642
  • adds var_in_glob test
  • updates Equals check to consider nil MapKeys (spread substitution into map has no map key)
  • would occur when comparing RefContexts to find the glob context

substitution can have nil MapKey

(d2ast.MapNodeBox) {
 Comment: (*d2ast.Comment)(<nil>),
 BlockComment: (*d2ast.BlockComment)(<nil>),
 Substitution: (*d2ast.Substitution)(0x14000519140)({
  Range: (d2ast.Range) 10:3,
  Spread: (bool) true,
  Path: ([]*d2ast.StringBox) (len=1 cap=1) {
   (*d2ast.StringBox)(0x140003f4c00)({
    UnquotedString: (*d2ast.UnquotedString)(0x140004285b0)({
     Range: (d2ast.Range) 10:8,
     Value: ([]d2ast.InterpolationBox) (len=1 cap=1) {
      (d2ast.InterpolationBox) {
       String: (*string)(0x14000f485c0)((len=1) "v"),
       StringRaw: (*string)(0x14000f485d0)((len=1) "v"),
       Substitution: (*d2ast.Substitution)(<nil>)
      }
     },
     Pattern: ([]string) <nil>
    }),
    DoubleQuotedString: (*d2ast.DoubleQuotedString)(<nil>),
    SingleQuotedString: (*d2ast.SingleQuotedString)(<nil>),
    BlockString: (*d2ast.BlockString)(<nil>)
   })
  }
 }),
 Import: (*d2ast.Import)(<nil>),
 MapKey: (*d2ast.Key)(<nil>)
}

@gavin-ts gavin-ts requested a review from alixander October 5, 2023 19:16
@gavin-ts gavin-ts marked this pull request as ready for review October 5, 2023 19:16
@gavin-ts gavin-ts enabled auto-merge October 5, 2023 19:19
@gavin-ts gavin-ts requested a review from alixander October 6, 2023 22:29
Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also get D2OracleEquals?

@gavin-ts gavin-ts requested a review from alixander October 6, 2023 23:05
@gavin-ts gavin-ts merged commit 318e628 into terrastruct:master Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic using var in glob

2 participants