Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-8101

Optional[] data type doesn't allow a parameter to be disabled

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Language, Type System
    • Labels:
      None
    • Template:
    • Method Found:
      Needs Assessment
    • QA Risk Assessment:
      Needs Assessment

      Description

      This is easiest to describe with a simple code example

      class example (
          Optional[String] $param = 'some non undef default value',
      ) {
          # $param can never be undef, no matter what you pass in
          # if you pass in undef, then the default is used
          # it's effectively impossible to "disable", even though it's Optional
      }
      

      Proposal:

      I would like the Optional type to be an enum of the passed in data type, Undef, and false. If that were the case, I could pass false to the class above and achieve the desired results. This could almost be done today with Variant[String, Boolean], but then the user could pass in true, which isn't a member of the desired set of input values.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              ben.ford Ben Ford
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support