Improve default argument processing #1102

Merged
merged 6 commits into from Jul 4, 2013

Conversation

Projects
None yet
5 participants
Member

9rnsr commented Sep 6, 2012

Discussion in forum:
http://forum.dlang.org/thread/mailman.1421.1346020012.31962.digitalmars-d@puremagic.com

Status improved:
Issue 3866 - anonymous delegate with default parameters cross-talks to another anonymous delegate
Fixed:
Issue 3646 - Default values of function arguments are ignored when instantiating a template.
Issue 8579 - Default parameter appears a part of typeof().stringof of a function variable


From commit log f5dc2257fd8c17a8c90b0906b174f25df494dc8b:

Default args and arg identifiers are now volatile information in TypeFunction.

  1. The extra informations would be kept after semantic analysis for function pointer and delegate types. But merging type would strip all the extras from the type structure, then cache the stripped copy into.
  2. The types has extra informations cannot be named. In other words, AliasDeclaration would always strip the aliased type. This rule also works for TemplateTypeParameter, and fixes issue 3646 well.
  3. CondExp would strip them from the type of its result.
Owner

andralex commented May 19, 2013

@WalterBright okay to merge?

WalterBright was assigned May 19, 2013

Owner

WalterBright commented Jun 28, 2013

I'll pull once the merge conflicts are resolved.

Member

9rnsr commented Jun 29, 2013

Ok, I rebased commits. Note that, currently this change would break test/compilable/cppmangle.d in linux platforms. I don't know C++ mangling well, so I couldn't understand the actual problem...

Owner

WalterBright commented Jun 29, 2013

Hmm, default args should not affect name mangling.

Member

yebblies commented Jun 29, 2013

@9rnsr Could you post the c++ mangling error you are seeing? I can't find it in the tester results.

Member

9rnsr commented Jun 29, 2013

@yebblies http://d.puremagic.com/test-results/pull.ghtml?projectid=1&runid=652536

../src/dmd -m32 -Icompilable   -odtest_results/compilable -oftest_results/compilable/cppmangle_0.o -c compilable/cppmangle.d
compilable/cppmangle.d(261): Error: static assert  ("_Z10test10058fPFPvS_EPFS_S_E"c == "_Z10test10058fPFPvS_ES1_") is false
Member

yebblies commented Jun 29, 2013

Ok, in C++ mangling types that are repeated can be referenced later with numbers. It looks like this is no longer happening in this case. I assume it's because pointer equality is used for comparison and the extra copying is making the type seem different.

9rnsr added some commits Sep 5, 2012

@9rnsr 9rnsr When we check two type objects equality, we should use Type::equals i…
…nstead of directly pointer comparison.
dd67c8c
@9rnsr 9rnsr Default args and arg identifiers are now volatile information in Type…
…Function.

1. The extra informations would be kept after semantic analysis for function pointer and delegate types. But merging type would strip all the extras from the type structure, then cache the stripped copy into.

2. The types has extra informations cannot be named. In other words, AliasDeclaration would always strip the aliased type. This rule also works for Template Type Parameter, and fixes issue 3646 well.

3. CondExp would strip them from the type of its result.
877e7bf
@9rnsr 9rnsr Improved fix for Issue 3866 - anonymous delegate with default paramet…
…ers cross-talks to another anonymous delegate

This reverts commit acc22ce,
and moves original test into runnable/functype.d
d736289
@9rnsr 9rnsr fix Issue 3646 - Default values of function arguments are ignored whe…
…n instantiating a template.
bce2d07
@9rnsr 9rnsr fix Issue 8579 - Default parameter appears a part of typeof().stringo…
…f of a function variable
864d5a3
@9rnsr 9rnsr Fix CppMangle issue
Use merge2() result for function argument types mangling.
8762713
Member

9rnsr commented Jun 29, 2013

@yebblies Thanks for the tip! I was able to fix the issue.

Member

9rnsr commented Jun 30, 2013

@WalterBright Now auto tester result is all green.

Member

yebblies commented Jul 4, 2013

Here goes...

@yebblies yebblies added a commit that referenced this pull request Jul 4, 2013

@yebblies yebblies Merge pull request #1102 from 9rnsr/improveDefArgs
Improve default argument processing
a711eb6

@yebblies yebblies merged commit a711eb6 into dlang:master Jul 4, 2013

1 check was pending

default Pass: 4, Pending: 6
Details
Contributor

yazd commented Jul 5, 2013

Owner

andralex commented Jul 10, 2013

@9rnsr @yebblies is there work on fixing the regression? thanks.

Member

9rnsr commented Jul 11, 2013

@andralex Yes. I fixed the regression in #2311, by changing little language semantic.

Owner

andralex commented Jul 12, 2013

@9rnsr awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment