Page MenuHomeFeedback Tracker

Calling HashMap methods w/o args uses parent _this
New, NormalPublic

Description

When calling any method of a HashMap or a HashMapObject without specified arguments, _this in the method code will be same as in the parent enviroment.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Category
General
Steps To Reproduce
[1, 2, 3] call {
    _hash = createHashMapObject [[
        ["MyMethod", { systemChat str _this }]
    ]];

    _hash call ["MyMethod"]; // prints [1,2,3]
    _hash call ["MyMethod", []]; // prints []
};
[1, 2, 3] call {
    _hash = createHashMapFromArray [
        ["MyMethod", { systemChat str _this }]
    ];

    _hash call ["MyMethod"]; // prints [1,2,3]
    _hash call ["MyMethod", []]; // prints []
};
Additional Information

Game version is 2.18.152746 (profiling branch)

Event Timeline

dedmen added a subscriber: dedmen.Tue, Apr 8, 2:08 PM

It behaves the same as
call x vs [] call x

Not sure what would be correct behavior here?
HashMapObject call, currently works same as normal call works, so I'd say this is by design

@dedmen according to syntax 3 https://community.bistudio.com/wiki/call#Syntax_3 _this in this case should be nil as expected