Operator overloads declared in a UDT produce the error message: Operator cannot be a member function (TODO)
For example,
type T
__ as integer
declare operator len( byref arg T ) as uinteger
end type
'' output
'' todo.bas(3) error 153: Operator cannot be a member function (TODO), before '(' in 'declare operator len( byref arg T ) as uinteger'
Either the the (TODO) should be removed, or static operator capability be added.
Propose that:
1) Initially, allow the static operator and continue to put overloaded operator in the global namespace. This is no worse than the bug reported at [#902] where overloaded operators do not respect namespace (A UDT is a kind of namespace).
2) Static operators (no instance pointer) are generally not allowed in C++ and mandatory in C#. fbc will define it's own rules
3) Static operators must have at least one parameter that match the parent UDT
4) Remove the "TODO" from the error message
For example:
type T
__ as integer
declare static operator len( byref arg as T ) as uinteger
end type
operator T.len( byref arg as T ) as uinteger
return 1
end operator
dim x as T
print len( x )
Pull request at https://github.com/freebasic/fbc/pull/149