YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

Optional struct parameter of a parent constructor is expected by Feather to be of type boolean when inheriting that constructor #4635

Open neerikiffu opened 9 months ago

neerikiffu commented 9 months ago

Description

When inheriting a constructor with an optional parameter of struct type, when setting the parent ctor after the colon and repeating the optional struct parameter, feather says it should be a boolean instead. The optional struct parameter also appears as type "any" in the parent struct.

Steps To Reproduce

project attached, but here have the code as well, defined in a script:

function ParentConstructor(_name, _struct = {}) constructor {}
function ChildConstructor(_name, _struct = {}, _otherStuff = []) : ParentConstructor(_name, _struct = {}) constructor {}

the _struct = {} in the parent constructor on line 2 shows feather GM1041 error "The type 'Bool' appears where the type 'Struct' is expected", even though it's literally a struct

383a8b3d-7cf0-4bc2-ae00-84bd9d2adb08

brenttaylor commented 9 months ago

Doesn't look to be a bug. You're trying to name a parameter in the call to ParentConstructor, which is technically being interpreted as an equality check.

This should work:

function ParentConstructor(_name, _struct = {}) constructor {}
function ChildConstructor(_name, _struct = {}, _otherStuff = []) : ParentConstructor(_name, _struct) constructor {}

Note the removal of _struct={} in the ParentConstructor call in favor of just _struct.

neerikiffu commented 9 months ago

i know nothing, zach asked me to report it and i did

thennothinghappened commented 9 months ago

I think this is more a confusing deal about how GM accepts = as equality, which is incredibly confusing and bug prone.

zreedy commented 9 months ago

To clear confusion, this bug report was requested as the wording of the Feather Message is confusing. The rules about = interpretation as an assignment vs equality is an easy stumble in GML and Feather should be extremely concise and clear in its messaging about this.

One way this could be cleared up is to specify what Feather sees explicitly (types, and variable names/expressions).

Type mismatch for argument '_struct' in function 'ParentConstructor' between the expected type 'Struct' and expression _struct = {} of type 'Bool'