DSC icon indicating copy to clipboard operation
DSC copied to clipboard

Lambda variables in `map()` function cannot be used as arguments to nested function calls

Open Gijsreyn opened this issue 1 month ago • 1 comments

Prerequisites

  • [x] Write a descriptive title.
  • [x] Make sure you are able to repro it on the latest version
  • [x] Search the existing issues.

Summary

I am experiencing a problem with using lambda variables from map() function as arguments to nested function calls in DSC expressions whilst working on #1230.

Steps to reproduce

  1. Create a DSC configuration with a map() expression that uses a lambda variable
  2. Pass the lambda variable as an argument to a function within the map body
  3. Execute the configuration

Example config:

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
  baseNetwork:
    type: string
    defaultValue: 10.144.0.0/20
  newPrefix:
    type: int
    defaultValue: 24
  subnetCount:
    type: int
    defaultValue: 5
resources:
  - name: Generate subnets
    type: Microsoft.DSC.Debug/Echo
    properties:
      output: "[map(range(0, parameters('subnetCount')), 'i', cidrSubnet(parameters('baseNetwork'), parameters('newPrefix'), i))]"

Expected behavior

The `map()` function should iterate over the range [0, 1, 2, 3, 4], pass each value as the lambda variable i, and successfully call `cidrSubnet()` with that variable as the third argument. The output should be an array of 5 subnet CIDR strings.

Actual behavior

ERROR Parser: Found error node parsing function

Error details


Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

dsc 3.2.0-preview.7

Visuals

No response

Gijsreyn avatar Nov 03 '25 02:11 Gijsreyn

Hold this one of for now, as no lamba expressions are there (yet). Regardless, it failed on expression evaluation.

Gijsreyn avatar Nov 03 '25 02:11 Gijsreyn