Am I missing something obvious here? Seems like all strings should work the same and call the property defined for String. When the string happens to be the name of the function, it calls the property defined for Func. Is there possibly a bug in the Func("Name") optimization code, or is this the expected behavior?
Code: Select all
dp := {}.getmethod('defineprop')
%dp%(''.base, 'p', {get : (*)=>'string'}) ;defined string.p
%dp%(func('ln').base, 'p', {get : (*)=>'func'}) ;defined func.p
but_func_names() => '' ;func that happens to exist
msgbox('works_on_any_string'.p) ;calls string property
msgbox('but_func_names'.p) ;BUG? calls func property!
n := '_names', msgbox(('but_func' n).p) ;doesn't have to be a literal
In a more complicated script, it took me a while to figure out why the string property wasn't executing. The existence of a function name (by chance) matching the string appeared to be why. That's what led me to test extending the Func prototype to see if it was somehow getting converted. Any help you can lend would be much appreciated!