Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

GMEdit

A high-end code editor for all things GameMaker · By YellowAfterlife

[Bug]Beta : Shortand type for functions inside structs not working as expected

A topic by davawen created Feb 13, 2021 Views: 163 Replies: 1
Viewing posts 1 to 2
(8 edits)

Hello again!

I have seen a bug with functions inside structs where shortand types are commented out.
Creating a function with shortand types work as expected :

    function foo(bar: number)->void {}

However, functions inside structs automatically comment shortand types, so typing this :

    function foo() constructor
    {
            function bar(baz: number)-> void {}
    }

Then saving gives this :

    function foo() constructor
    {
            function bar(baz/*: number*/)/*-> void*/ {}
    }

It is to be noted that methods inside structs do work as expected, typing this then saving does not change anything :

    function foo() constructor
    {
            bar = function(baz: number)->void {}
    }

  

Developer

I will look into this, but also you shouldn’t be using function name() inside constructors - doing so gives each constructor instance its own set of function references, unnecessarily using memory. For example,

function C() constructor {
	function f() {}
	static s = function() {}
}
function scr_hello() {
	var a = new C(), b = new C();
	trace("s", a.s == b.s);
	trace("f", a.f == b.f);
}

would show “s 1” “f 0”.