Skip to content

IES does not call functions on operator overloads, if omitting parens #21085

Open
@ArthaTi

Description

@ArthaTi

If parens are omitted on a function call performed inside of an interpolated expression passed to an operator overload — such as foo = i"$(helloWorld)" or foo ~ i"$(helloWorld)" — the function will not be called.

string helloWorld() {
    return "Hello, World!";
}

struct Foo {
    void opAssign(Ts...)(Ts) {
      
    }
    void fun(Ts...)(Ts) {
        
    }
}

void main() {
    Foo foo;
    foo.fun(i"$(helloWorld)");  // works
    foo = i"$(helloWorld)";     // fails
}

The error message is also very confusing, because it does not point to the invocation, but only to the template:

onlineapp.d(6): Error: cannot have parameter of function type `string()`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions