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

Fix panic with var in glob #1643

Merged
merged 7 commits into from
Oct 6, 2023
Merged

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 marked this pull request as ready for review October 5, 2023 19:16
d2ast/d2ast.go Show resolved Hide resolved
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 merged commit 318e628 into terrastruct:master Oct 6, 2023
2 checks passed
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