Jump to page: 1 2
Thread overview
[Issue 22541] DIP1000: Resolve ambiguity of ref-return-scope parameters
[Issue 22541] Resolve ambiguity of ref-return-scope parameters
Nov 24, 2021
Walter Bright
Nov 24, 2021
Walter Bright
Nov 24, 2021
Walter Bright
Nov 24, 2021
Dennis
Nov 25, 2021
Dlang Bot
Nov 30, 2021
Walter Bright
Nov 30, 2021
Dennis
Jan 24, 2022
Dlang Bot
Feb 16, 2022
Dennis
Feb 17, 2022
Dlang Bot
Feb 17, 2022
Dlang Bot
November 24, 2021
https://issues.dlang.org/show_bug.cgi?id=22541

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe

--
November 24, 2021
https://issues.dlang.org/show_bug.cgi?id=22541

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Resolve ambiguity of        |DIP1000: Resolve ambiguity
                   |ref-return-scope parameters |of ref-return-scope
                   |                            |parameters

--
November 24, 2021
https://issues.dlang.org/show_bug.cgi?id=22541

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
For struct member functions:

  struct S {
     T foo() return scope { ... }
  }

the first parameter is `ref S`. But the ambiguity is resolved by allowing `ref` to appear after the `foo()`, as in:

    T foo() return ref scope { ... }  // returnRef scope
    T foo() ref return scope { ... }  // ref returnScope

--
November 24, 2021
https://issues.dlang.org/show_bug.cgi?id=22541

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel@live.nl

--- Comment #2 from Dennis <dkorpel@live.nl> ---
I do like the idea of looking for adjacent `return scope`.
I don't like the complexity behind rules a..e, I'd rather simplify it than add
on top of that, so how about an alternative proposal:

When adjacent keywords `return scope` are present, the result is `ref returnScope`. Everything else results in `returnRef scope`.

You can make returnRef member functions with `scope return`, no new grammar needed. It also covers issue 20881.

--
November 25, 2021
https://issues.dlang.org/show_bug.cgi?id=22541

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

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

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #13357 "fix Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope para…" fixing this issue:

- fix Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope parameters

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

--
November 30, 2021
https://issues.dlang.org/show_bug.cgi?id=22541

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
Where I'd like to go is only allow "return ref" or "return scope". In the meantime, backwards compatibility will do for the first iteration.

--
November 30, 2021
https://issues.dlang.org/show_bug.cgi?id=22541

--- Comment #5 from Dennis <dkorpel@live.nl> ---
(In reply to Walter Bright from comment #4)
> Where I'd like to go is only allow "return ref" or "return scope". In the meantime, backwards compatibility will do for the first iteration.

Yes, let's do that!

--
January 24, 2022
https://issues.dlang.org/show_bug.cgi?id=22541

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #13357 "fix Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope para…" was merged into master:

- 7754800627f4f37bc16e49d123cd6db6597e7c3a by Walter Bright:
  fix Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope parameters

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

--
February 16, 2022
https://issues.dlang.org/show_bug.cgi?id=22541

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #7 from Dennis <dkorpel@live.nl> ---
As mentioned in the PR, that was only a partial fix, this still fails:
```
struct S
{
    int i;
    int* ptr;

    int* wannabeReturnRef() scope return
    {
        return &i;
    }
}
```

Error: returning `&this.i` escapes a reference to parameter `this`
       perhaps remove `scope` parameter annotation so `return` applies to `ref`

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

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #13677 "fix Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope para…" fixing this issue:

- fix Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope parameters

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

--
« First   ‹ Prev
1 2