[a122] wrong string property call when string is name of func

Report problems with documented functionality
sirksel
Posts: 89
Joined: 12 Nov 2013, 23:48

[a122] wrong string property call when string is name of func

18 Sep 2020, 08:14

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!
swagfag
Posts: 4026
Joined: 11 Jan 2017, 17:59

Re: [a122] wrong string property call when string is name of func

23 Sep 2020, 19:41

id consider it a bug. its not expected nor is it documented

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 5 guests