Skip to content

Clarify that function definitions must be placed before calls to them (no function hoisting) #8370

@mklement0

Description

@mklement0

Prerequisites

  • Write a descriptive title.
  • Search the existing issues.
  • I am reporting the documentation problem for version of PowerShell I am using.

Version

5.1, 7.0, 7.1, 7.2, Preview version

Link to affected document

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Functions?view=powershell-7.2

Description of the documentation error

Many languages have a feature called function hoisting, where a function definition is "hoisted" to the top of the scope so that you may place calls to that function before its definition.

By contrast, PowerShell requires placing function definitions before calls to these functions, which constitutes a pitfall for users coming from other languages.

Suggested fix

Amend the "Long description" to describe this pitfall.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-aboutArea - About_ topics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions