Skip to content

Comments

Issue 10249 - incorrect mangling for overloaded symbol#2125

Merged
WalterBright merged 1 commit intodlang:masterfrom
9rnsr:fix10249
Jun 24, 2013
Merged

Issue 10249 - incorrect mangling for overloaded symbol#2125
WalterBright merged 1 commit intodlang:masterfrom
9rnsr:fix10249

Conversation

@9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Jun 3, 2013

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 3, 2013

Don't merge this yet.

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 3, 2013

Ok. Ready to merge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A brief documentation? At least for the new code :o).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll write.

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 3, 2013

OK. Updated code.

@andralex
Copy link
Member

andralex commented Jun 3, 2013

lgtm, anyone up for a semantic review?

@WalterBright
Copy link
Member

What is the difference between mangle() and mangleExact()? I don't understand what is happening in the code, and how 10249 is fixed. Can you please provide some comments in the code?

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 5, 2013

@WalterBright
Currently mangle() returns the exact mangled name of the root function in overloads.

module test;
void foo(long) {}       // _D4test3fooFlZv
void foo(string) {}     // _D4test3fooFAyaZv
pragma(msg, foo.mangleof);
// Currently prints "_D4test3fooFlZv", which is calculated by
// `FuncDeclaration::mangle()` of void foo(long)

But this is not good. foo is overloaded name, so its mangled name should be neither _D4test3fooFlZv nor _D4test3fooFAyaZv. That's the core issue in 10249

After the change, mangle() returns the exact mangled name by calling mangleExact() only when actually the function has no overloads.

pragma(msg, foo.mangleof);
// After this change, prints "4test3foo" by calling `Dsymbol::mangle()`,
// instead of `FuncDeclaration::mangleExact()`.
pragma(msg, __traits(getOverloads, test, "foo")[0].mangleof);  // _D4test3fooFlZv
pragma(msg, __traits(getOverloads, test, "foo")[1].mangleof);  // _D4test3fooFAyaZv

If a function has no overloads, .mangleof property still returns exact mangled name.

void bar() {}
pragma(msg, bar.mangleof);
// still prints _D4test3barFZv by calling `FuncDeclaration::mangleExact()` from `FuncDeclaration::mangle()`.

@WalterBright
Copy link
Member

Thanks for the explanation! Can you please add these as comments in the code?

@9rnsr
Copy link
Contributor Author

9rnsr commented Jun 9, 2013

@WalterBright OK. Updated code comment on FuncDeclaration::mangle()

WalterBright added a commit that referenced this pull request Jun 24, 2013
Issue 10249 - incorrect mangling for overloaded symbol
@WalterBright WalterBright merged commit 7109d78 into dlang:master Jun 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants