Skip to content

Conversation

SteveL-MSFT
Copy link
Member

PR Summary

The grammar for expressions was not allowing: [createObject('a',1)['a'] to work which is supported by ARM. This also allows the property name to be an expression.

In the grammar, we allow for a single-quoted string in addition to an expression or number. Then in the parser, we handle this additional index kind. During execution, we detect if the index is a string and try to get the object property by that name.

Also fixed debug tracing so the contents of the Node are emitted instead of the struct.

PR Context

Fix #1180

@SteveL-MSFT SteveL-MSFT requested review from Copilot and tgauth October 13, 2025 23:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables expressions to use index accessor for object properties, allowing syntax like [createObject('a',1)['a']] which is supported by ARM templates. The changes extend the grammar to support single-quoted strings as property names and update the parser to handle string-based property access on objects.

Key changes:

  • Extended grammar to support property names as index values in addition to expressions and numbers
  • Added string-based object property access in the expression parser
  • Improved debug tracing to display node contents instead of struct representations

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/dsc-lib/src/parser/expressions.rs Added support for string-based object property access and improved debug output
lib/dsc-lib/locales/en-us.toml Updated debug messages and added new error message keys
grammars/tree-sitter-dscexpression/grammar.js Extended grammar to support propertyName in index accessor
grammars/tree-sitter-dscexpression/test/corpus/valid_expressions.txt Added test case for object index syntax
grammars/tree-sitter-dscexpression/test/corpus/invalid_expressions.txt Added test case for invalid object index without quotes
dsc/tests/dsc_expressions.tests.ps1 Added comprehensive test cases for string-based property access

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@SteveL-MSFT SteveL-MSFT enabled auto-merge October 15, 2025 20:01
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Oct 15, 2025
Merged via the queue into PowerShell:main with commit 735d319 Oct 15, 2025
19 checks passed
@SteveL-MSFT SteveL-MSFT deleted the dynamic-index branch October 15, 2025 20:01
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.

Dynamic dot notation parser error

2 participants