Page MenuHomePhabricator

Constructor for Positive Integer doesn't resolve argument
Closed, ResolvedPublicBUG REPORT

Description

I have a type Positive Integer that consists of one key of type String. This is the type, it is Z10022 in my installation:

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z10022"
    },
    "Z2K2": {
        "Z1K1": "Z4",
        "Z4K1": "Z10022",
        "Z4K2": {
            "Z1K1": {
                "Z1K1": "Z7",
                "Z7K1": "Z881",
                "Z881K1": "Z3"
            },
            "K1": {
                "Z1K1": "Z3",
                "Z3K1": "Z6",
                "Z3K2": {
                    "Z1K1": "Z6",
                    "Z6K1": "Z10022K1"
                },
                "Z3K3": {
                    "Z1K1": "Z12",
                    "Z12K1": [
                        {
                            "Z1K1": "Z11",
                            "Z11K1": "Z1002",
                            "Z11K2": "value"
                        }
                    ]
                }
            },
            "K2": {
                "Z1K1": {
                    "Z1K1": "Z7",
                    "Z7K1": "Z881",
                    "Z881K1": "Z3"
                }
            }
        },
        "Z4K3": "Z101"
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Positive integer"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            {
                "Z1K1": "Z31",
                "Z31K1": "Z1002",
                "Z31K2": []
            }
        ]
    }
}

Now I want to create a function that takes a string and returns a positive integer. This is the function definition (Z10095 in my wiki):

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z10095"
    },
    "Z2K2": {
        "Z1K1": "Z8",
        "Z8K1": [
            {
                "Z1K1": "Z17",
                "Z17K1": "Z6",
                "Z17K2": {
                    "Z1K1": "Z6",
                    "Z6K1": "Z10095K1"
                },
                "Z17K3": {
                    "Z1K1": "Z12",
                    "Z12K1": [
                        {
                            "Z1K1": "Z11",
                            "Z11K1": "Z1002",
                            "Z11K2": "input"
                        }
                    ]
                }
            }
        ],
        "Z8K2": "Z10022",
        "Z8K3": [],
        "Z8K4": [
            "Z10096"
        ],
        "Z8K5": "Z10095"
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Positive Integer constructor"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            {
                "Z1K1": "Z31",
                "Z31K1": "Z1002",
                "Z31K2": []
            }
        ]
    }
}

I tried several implementations, but the following ones I thought used to work but don't work anymore. So this implementation is taking the literal and placing the argument in the right place:

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z10096"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z10095",
        "Z14K2": {
            "Z1K1": "Z10022",
            "Z10022K1": {
                "Z1K1": "Z18",
                "Z18K1": {
                    "Z1K1": "Z6",
                    "Z6K1": "Z10095K1"
                }
            }
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Composition of Positive Integer constructor"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            {
                "Z1K1": "Z31",
                "Z31K1": "Z1002",
                "Z31K2": []
            }
        ]
    }
}

When I do that and then I call the function like this:

{
  "Z1K1": "Z7",
  "Z7K1": "Z10095",
  "Z10095K1": {
    "Z1K1": "Z6",
    "Z6K1": "5"
  }
}

I get the following result:

{
  "Z1K1": "Z22",
  "Z22K1": {
    "Z1K1": {
      "Z1K1": "Z4",
      "Z4K1": "Z10022",
      "Z4K2": [
        {
          "Z1K1": "Z3",
          "Z3K1": "Z6",
          "Z3K2": "Z10022K1",
          "Z3K3": {
            "Z1K1": "Z12",
            "Z12K1": [
              {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "value"
              }
            ]
          }
        }
      ],
      "Z4K3": {
        "Z1K1": "Z8",
        "Z8K1": [
          {
            "Z1K1": "Z17",
            "Z17K1": "Z1",
            "Z17K2": "Z101K1",
            "Z17K3": {
              "Z1K1": "Z12",
              "Z12K1": []
            }
          }
        ],
        "Z8K2": "Z1",
        "Z8K3": [],
        "Z8K4": [
          {
            "Z1K1": "Z14",
            "Z14K1": "Z101",
            "Z14K4": {
              "Z1K1": "Z6",
              "Z6K1": "Z201"
            }
          }
        ],
        "Z8K5": "Z101"
      }
    },
    "Z10022K1": {
      "Z1K1": "Z18",
      "Z18K1": "Z10095K1"
    }
  },
  "Z22K2": "Z23"
}

but it should be

{
  "Z1K1": "Z10022",
  "Z10022K1": "5"
}

Sprinkling some Z801/Echo calls doesn't improve the situation, unfortunately.

Event Timeline

DVrandecic updated the task description. (Show Details)
DVrandecic updated the task description. (Show Details)
DVrandecic updated the task description. (Show Details)
DVrandecic updated the task description. (Show Details)
DVrandecic updated the task description. (Show Details)
DVrandecic updated the task description. (Show Details)

Can we move this to phase Theta?

Can this be a fix-it week task?

This may well be fixed when we fix currying (I'm not sure).

Change 779080 had a related patch set uploaded (by Cory Massaro; author: Cory Massaro):

[mediawiki/services/function-orchestrator@master] Add test for a function that constructs a user-defined type from an argument.

https://gerrit.wikimedia.org/r/779080

This was fixed when we fixed this task. I have added your exact ZObjects (ZIDs changed for anonymity) as a test in the orchestrator.

Change 779080 merged by jenkins-bot:

[mediawiki/services/function-orchestrator@master] Add test for a function that constructs a user-defined type from an argument.

https://gerrit.wikimedia.org/r/779080