The suggested solution in the answer https://mapleprimes.com/questions/234325-Use-Of-self--Inside-Object-Constructor worked OK in the setup shown in that question.
But it does not work when putting the constructor inside overload
Here is an example where it works (i.e. by removing the type from _self as suggested in the above answer)
restart;
person:=module()
option object;
local name::string:="";
#notice no _self::person, just _self
export ModuleCopy::static:= proc( _self, proto::person, the_name::string, $ )
name:= the_name;
end proc;
end module;
p:=Object(person,"me")
The above works. But since I have different constructors, once I put the above inside overload, using the same exact syntax, now the error comes back
restart;
person:=module()
option object;
local name::string:="";
export ModuleCopy::static:= overload(
[
proc( _self, proto::person, the_name::string, $ ) option overload;
name:= the_name;
end proc
]);
end module;
p:=Object(person,"me")
Error, static procedure `ModuleCopy` refers to non-static local or export `name::string` in surrounding scope
I did not expect that using overload will cause any change to how it behaves. Is this a bug?
Below is worksheet also.
Download OO_version.mw