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 3235 & 6714 - [tdpl] Improve function literal deduction #588

Merged
merged 8 commits into from
Dec 31, 2011

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Dec 29, 2011

Issue 3235 - [tdpl] Function literals must be deduced as "function" or "delegate"
Issue 6714 - [tdpl] Type inference for parameters of function and delegate literals

Features:

  • All of function literals that require parameter type inference are rewritten to template literal.
  • Parameter types and function/delegate inference works in following places:
    Var declaration, return statement, caller (CallExp::e1), and argument of function call.

A small breaking of existing code:

Past normal function literals, not in template arguments, are can omit parameter names.

e.g. (string, size_t){ return 1024; }

But this change regards them as parameter type omission, then raises an error.

Supplemental changes of Phobos:
dlang/phobos#381

@9rnsr 9rnsr closed this Dec 30, 2011
FuncExp::setType should be called first, and later semantic() resolve parameter types from tded.
1. The first FuncExp::semantic() call saves scope.
2. Next FuncExp::inferType() tries to resolve parameter types.
3. And finally setType() + semantic() determine the actual type (see functionParameters).
If FuncLiteralDeclaration::tok == TOKreserved, it is lambda declaration that is not yet determined as neither function or delegate.
Bad covariant conversion from float(int,int) to double(int,int) was incorrectly allowed.
@9rnsr 9rnsr reopened this Dec 31, 2011
@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 31, 2011

Whole improvement for bug 3235.

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 31, 2011

If you merge this pull, please merge dlang/phobos#381 at the same time.

WalterBright added a commit that referenced this pull request Dec 31, 2011
Issue 3235 & 6714 - [tdpl] Improve function literal deduction
@WalterBright WalterBright merged commit c50eb5f into dlang:master Dec 31, 2011
@ghost
Copy link

ghost commented Dec 31, 2011

Why is it OK to break existing code? Was this breaking change discussed in the NG?

@WalterBright
Copy link
Member

On 12/31/2011 9:00 AM, Andrej Mitrovic wrote:

Why is it OK to break existing code? Was this breaking change discussed in the NG?

The deciding factor for me was the improvement in code performance.

@9rnsr
Copy link
Contributor Author

9rnsr commented Jan 3, 2012

@WalterBright, this change was a bit fragile.
Please merge #593 as soon as possible.

braddr pushed a commit to braddr/dmd that referenced this pull request Oct 22, 2012
Issue 8112 - std.algorithm.fill must accept InputRange
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.

2 participants