YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

json_stringify does not properly serialize built in functions #7312

Closed attic-stuff closed 2 months ago

attic-stuff commented 2 months ago

Description

when you json_stringify() a user script function you get a proper ref out of it, but when you try to json_stringify() a built in function you just get its numerical index :(

function funny_math(a = 400, b = 20) {
    return a + b;   
}

var booty = { thing_to_do : funny_math };
show_message(json_stringify(booty)); //shows ref

var tooty = { thing_to_do : dot_product_3d_normalized };
show_message(json_stringify(tooty)); //shows 318

the attached file shows this. its a yyz renamed to a zip so u gotta rename it yourself, hackermans style.

json_bourne.zip

Expected Change

json_stringify() should return a right and good and proper ref for built in functions

Steps To Reproduce

  1. Start GameMaker
  2. serialize a built in function reference with json_stringify
  3. See the issue

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

2024.6.2 (Monthly)

Which platform(s) are you seeing the problem on?

Windows

Contact Us Package Attached?

Sample Project Added?

rwkay commented 2 months ago

On current runtime this is not currently possible as the script reference is just a number and not a handle (it is not a resource)....

As it currently stands this would be very problematic to add / fix