Page MenuHomePhabricator

Errors from implementations in JavaScript or Python when the function’s return type is Z1/object or a Z1-typed list and the implementations return an array of integers or numbers
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
JavaScript error: "bigint are forbidden in JSON.stringify"
Python error: "[2024-07-14 12:59:36.486] [error] execution failed: unreachable, Code: 0x89\n[2024-07-14 12:59:36.486] [error] When executing function name: \"_start\""

What should have happened instead?:
A singleton list of type Natural number containing the value 12345 should have been returned (see result for Z901).

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):
I tried editing the implementations to simply return an array containing an int. These had similar failures. JavaScript also fails when the array is a number, error: "Could not serialize input JS object: Number 801"

Related errors occur on function https://www.wikifunctions.org/view/en/Z12668. Z17702 fails with all implementations.

(On the other hand, https://www.wikifunctions.org/view/en/Z13727 successfully returns a Natural number list (presumably because that is explicit in the function definition).)

Event Timeline

GrounderUK renamed this task from Arrays of ints or bigints produce errors when returning a Typed list as a Z1/object to Errors from implementations in JavaScript or Python when the function’s return type is Z1/object and the implementations return an array of integers or numbers.Jul 15 2024, 10:38 AM

The problem seems to extend to functions where the return type is a Z1-typed list. From my comment on https://www.wikifunctions.org/view/en/Z16430, I assume that we used to get an unaltered list back, rather than the current errors.

GrounderUK renamed this task from Errors from implementations in JavaScript or Python when the function’s return type is Z1/object and the implementations return an array of integers or numbers to Errors from implementations in JavaScript or Python when the function’s return type is Z1/object or a Z1-typed list and the implementations return an array of integers or numbers.Jul 15 2024, 2:18 PM

For now, we don't support type conversion on untyped lists, or on functions that return a Z1. That's indeed a missing feature still.

For now, we don't support type conversion on untyped lists, or on functions that return a Z1. That's indeed a missing feature still.

Okay, but now we can reverse (or find the last element of) an untyped list of integers, months… whatever, but we can’t reverse a typed list without creating a specific function for that type of list. Please see other examples at https://www.wikifunctions.org/wiki/Wikifunctions:Catalogue#Functions_with_list_outputs.

I think it would help here if we could have a function to convert a typed list into an untyped list, as a matter of priority. It does not appear to be possible to write such a function (note failing implementations for Z801 with test https://www.wikifunctions.org/view/en/Z17799).

Yes it does seem strange to me that https://www.wikifunctions.org/view/en/Z13725 works. So untyping lists could be a useful (but strange!) workaround.

@DVrandecic Just to be clear. It is TYPED lists that fail. UNTYPED (Z1) lists are fine.

I think it would help here if we could have a function to convert a typed list into an untyped list, as a matter of priority. It does not appear to be possible to write such a function.

We have now created https://www.wikifunctions.org/view/en/Z17895, which exploits a loophole in Z973. This means we will not need a built-in implementation (or equivalent function), so long as Z973 continues to return a Z1-typed list.