Thread overview
[Issue 2753] Cannot declare pointer to function returning ref
Oct 25, 2022
Bolpat
Oct 25, 2022
Dlang Bot
Dec 17, 2022
Iain Buclaw
May 17, 2023
Dlang Bot
May 17, 2023
Dlang Bot
May 26, 2023
Dlang Bot
May 26, 2023
Dlang Bot
October 25, 2022
https://issues.dlang.org/show_bug.cgi?id=2753

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qs.il.paperinik@gmail.com

--- Comment #10 from Bolpat <qs.il.paperinik@gmail.com> ---
@Walter: It is “broken” in the sense that the grammar should(!) be able to express a type without requiring type aliases.

I’d suggest minimal changes to the Type grammar to allow for it.

TL;DR: The semantics is obvious, I hope. Let’s allow the following:
```d
ref (int function()) f1();
(ref int function()) f2();

void g1(ref (int function()) fp);
void g2((ref int function()) fp);

void hImpl(DG : ref int delegate())(DG dg) { }
alias h = fImpl!(ref int delegate() @safe);
```
――― End of TL;DR ―――

Note that `f1` and `g1` are equivalent to:
```d
ref int function() f1();
void g1(ref int function() fp);
```

In the grammar, I use `?` to signify optional occurrence.

```diff
  Type:
      TypeCtors? BasicType TypeSuffixes?
+     ref TypeCtors? BasicType CallableSuffix TypeSuffixes?

    BasicType:
        FundamentalType
        . QualifiedIdentifier
        QualifiedIdentifier
        Typeof
        Typeof . QualifiedIdentifier
−       TypeCtor ( Type )
+       TypeCtor? ( Type )
        Vector
        TraitsExpression
        MixinType

    TypeSuffix:
        *
        [ ]
        [ AssignExpression ]
        [ AssignExpression .. AssignExpression ]
        [ Type ]
+       CallableSuffix
+
+   CallableSuffix:
        delegate Parameters MemberFunctionAttributes?
        function Parameters FunctionAttributes?
```
(This grammar diff does not address the special casing for `alias` that is
currently in place and superseded by this. As far as I can tell, it’ll be still
good and should not be changed.)

It is worth considering to deprecate the syntax without disambiguating parentheses, akin to comparison and bit-wise operators and `() => { }`. The deprecation only applies to cases where a non-aliased function pointer or delegate type is used on a `ref` parameter or as the return type of a `ref` returning function.

--
October 25, 2022
https://issues.dlang.org/show_bug.cgi?id=2753

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #11 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Bolpat created dlang/dlang.org pull request #3446 "Fix Issue 2753" fixing this issue:

- Fix Issue 2753

https://github.com/dlang/dlang.org/pull/3446

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=2753

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--
May 17, 2023
https://issues.dlang.org/show_bug.cgi?id=2753

--- Comment #12 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ntrel updated dlang/dmd pull request #15243 "[new syntax] Support `function` `ref` Type Parameters for function pointer types" fixing this issue:

- Fix Issue 2753 - Cannot declare pointer to function returning ref.

https://github.com/dlang/dmd/pull/15243

--
May 17, 2023
https://issues.dlang.org/show_bug.cgi?id=2753

--- Comment #13 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Bolpat updated dlang/dmd pull request #15245 "Fix Issue 2753" fixing this issue:

- Fix issue 2753 - add good case tests

https://github.com/dlang/dmd/pull/15245

--
May 26, 2023
https://issues.dlang.org/show_bug.cgi?id=2753

--- Comment #14 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Bolpat created dlang/dlang.org pull request #3616 "Primary Type Syntax" fixing this issue:

- Fix Issue 2753

https://github.com/dlang/dlang.org/pull/3616

--
May 26, 2023
https://issues.dlang.org/show_bug.cgi?id=2753

--- Comment #15 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Bolpat created dlang/dmd pull request #15269 "Primary Type Syntax" fixing this issue:

- Fix issue 2753 - add good case tests

https://github.com/dlang/dmd/pull/15269

--
November 08
https://issues.dlang.org/show_bug.cgi?id=2753

--- Comment #16 from Nick Treleaven <nick@geany.org> ---
*** Issue 21521 has been marked as a duplicate of this issue. ***

--