YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
22 stars 8 forks source link

GMRT: Behaviour when calling constructor without "new" keyword differs to GMS2 runtime #7507

Open HannulaTero opened 2 weeks ago

HannulaTero commented 2 weeks ago

Description

Behaviour when calling another constructor function without "new" keyword inside constructor is different between GMS2 Runtime and GMRT. Doing this in GMRT will change static/parent of struct.

Although I don't usually use constructors functions like normal functions, I would thing expected behaviour should be like GMS2 Runtime has.

Steps To Reproduce

1) Create constructor function Thing() 2) Create constructor function whoopse() 3) Inside Thing constructor, call whoopsie without using "new". 4) Create a new Thing. 4a) In GMS2 Runtime you get struct of Thing, which executed whoopsie. 4b) In GMRT you get struct of whoopsie. 5) Check with instanceof(...)

/// @func Thing();
/// @desc 
function Thing() constructor
{
  // Call whoopsy like normal function.
  show_debug_message($"instanceof: {instanceof(self)}");
  whoopsy();
  show_debug_message($"instanceof: {instanceof(self)}");
}

/// @func whoopsy();
/// @desc This function has "misplaced" constructor -keyword,
function whoopsy() constructor
{
  show_debug_message("Whoopsy.");
}

// Create Thing-struct.
var _thing = new Thing();

/*
In GMS2 Runtime result is: 
  instanceof: Thing
  Whoopsy.
  instanceof: Thing

In GMRT Result is: 
  instanceof: Thing
  Whoopsy.
  instanceof: whoopsy
*/

Which version of GameMaker are you reporting this issue for?

IDE v2024.800.0.618 Runtime v2024.800.0.642

Which operating system(s) are you seeing the problem on?

Windows 10.0.19045.0

aed7ebe2-24a5-417a-8ad7-3dda67640ae7

kat-fl commented 3 days ago

After a discussion with Russell, this is actually a bug in the current runtime VM which should be fixed. The behaviour will not change on GMRT, see also #7690.

YYDan commented 3 days ago

So this issue is to be closed as Not Planned and instead 7690 is going to be changed?

kat-fl commented 3 days ago

There is a minor quirk with the VM right now which needs to be resolved so it's on parity with YYC and GMRT, so I've kept this issue open for now. 7690 is a separate, additional thing.

rwkay commented 2 days ago

7690 is now implemented and VM, YYC and HTML5 now all error when a constructor is not called from new