Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 9271 - Forwarding lambda predicate with type inference causes segfault #2877

Merged
merged 1 commit into from Nov 25, 2013

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Nov 25, 2013

https://d.puremagic.com/issues/show_bug.cgi?id=9271

Root cause is in the wrong mangling scheme for nested templates.

Currently, if TemplateInstance::enclosing != NULL, enclosing is preferentially used for the parent of mangled name.
However, if same name templates are instantiated with same nested arguments, their mangled name will conflict.

It can be checked by using dmd debug print at the end of FuncDeclaration::semantic3.

Current:

-FuncDeclaration::semantic3('any!(__lambda1, string[]).any', sc = 003D92A0, loc = imports\test9271a.d(3))
        mangle() = _D8test92714mainFZv30__T3anyS14main9__lambda1TAAyaZ3anyMFNaNbNfAAyaZb**
-FuncDeclaration::semantic3('any!((e) => e == "asd", string[]).any', sc = 003D8100, loc = test9271.d(5))
        mangle() = _D8test92714mainFZv30__T3anyS14main9__lambda1TAAyaZ3anyMFNaNbNfAAyaZb

After merging this PR, they will be fixed to:

-FuncDeclaration::semantic3('any!(__lambda1, string[]).any', sc = 01B192A0, loc = imports\test9271a.d(3))
        mangle() = _D7imports9test9271a3any30__T3anyS14main9__lambda1TAAyaZ3anyMFNaNbNfAAyaZb
-FuncDeclaration::semantic3('any!((e) => e == "asd", string[]).any', sc = 01B18100, loc = test9271.d(5))
        mangle() = _D8test92713any30__T3anyS14main9__lambda1TAAyaZ3anyMFNaNbNfAAyaZb

@9rnsr
Copy link
Contributor Author

9rnsr commented Nov 25, 2013

Note that, enclosing scope is implicitly mangled in the TemplateInstance arguments:

eg. _D8test92713any30__T3anyS14main9__lambda1TAAyaZ3anyMFNaNbNfAAyaZb

So any information won't be lost by this change.

@braddr
Copy link
Member

braddr commented Nov 25, 2013

Auto-merge toggled on

@braddr
Copy link
Member

braddr commented Nov 25, 2013

Auto-merge toggled off

@braddr
Copy link
Member

braddr commented Nov 25, 2013

Auto-merge toggled on

@braddr
Copy link
Member

braddr commented Nov 25, 2013

Auto-merge toggled off

@9rnsr
Copy link
Contributor Author

9rnsr commented Nov 25, 2013

Fix failures in test/runnable/nested.d and test/compilable/testInference.d.

@WalterBright
Copy link
Member

Auto-merge toggled on

WalterBright added a commit that referenced this pull request Nov 25, 2013
Issue 9271 - Forwarding lambda predicate with type inference causes segfault
@WalterBright WalterBright merged commit 7d23f86 into dlang:master Nov 25, 2013
@9rnsr 9rnsr deleted the fix9271 branch November 26, 2013 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants