Open neerikiffu opened 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
.
i know nothing, zach asked me to report it and i did
I think this is more a confusing deal about how GM accepts =
as equality, which is incredibly confusing and bug prone.
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'
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:
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 struct383a8b3d-7cf0-4bc2-ae00-84bd9d2adb08