Skip to content

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

@Gijsreyn

Description

@Gijsreyn

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions