WerWolv / PatternLanguage

The Pattern Language used by the ImHex Hex Editor
https://imhex.werwolv.net
GNU Lesser General Public License v2.1
173 stars 44 forks source link

Inconsistent requirement for scope resolution qualification of functions vs custom types #85

Open paxcut opened 7 months ago

paxcut commented 7 months ago

A user-defined type declared inside a namespace can be used inside the namespace without full qualification (aka explicit full scope resolution in name) but functions seem to require the use of their full names regardless of location of usage.

Consider the following declarations:

namespace ns {
    struct S {
        u8 c = 3;
    };

    fn fun(auto arg) {
        return arg+1;
    };
}

Using them the following code runs correctly:

import std.io as io;
namespace ns {

    S s;
    io::print("{}",ns::fun(s.c));
}

but dropping the full name from fun causes an error indicating that the function could not be found as shown in the next image. Either both S and fun should need their full name or neither should.

image