D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22868 - __traits(parameters) returns parameters of delegate instead of function
Summary: __traits(parameters) returns parameters of delegate instead of function
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-03-10 23:50 UTC by moonlightsentinel
Modified: 2022-03-27 02:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description moonlightsentinel 2022-03-10 23:50:48 UTC
__traits(parameters) currently yields the parameters of the delegate when the foreach iterates over an aggregate using opApply. This is wrong and leaks an implementation detail into user code.

See the discussion thread here: https://forum.dlang.org/thread/vdqehddiompdoehhwewf@forum.dlang.org
Comment 1 Dlang Bot 2022-03-10 23:56:15 UTC
@MoonlightSentinel created dlang/dmd pull request #13798 "Fix 22868 - Let __traits(parameters) see past opApply delegates" fixing this issue:

- Fix 22868 - Let __traits(parameters) see past opApply delegates
  
  Ensure that `__traits(parameters)` consistently returns the parameters
  of the enclosing functions and doesn't return the parameters of the
  `opApply` delegate - leaking an implementation detail.

https://github.com/dlang/dmd/pull/13798
Comment 2 Dlang Bot 2022-03-11 14:29:25 UTC
@MoonlightSentinel created dlang/dmd pull request #13804 "alias parameters" fixing this issue:

- Fix 22868 - Let __traits(parameters) see past opApply delegates
  
  Ensure that `__traits(parameters)` consistently returns the parameters
  of the enclosing function and instead of the parameters of the
  `opApply` delegate (leaking an implementation detail).
  
  Also added a bunch of tests - the parts hidden by `version (Fixed)`
  fail due to another bug.

https://github.com/dlang/dmd/pull/13804
Comment 3 Dlang Bot 2022-03-12 16:43:33 UTC
dlang/dmd pull request #13798 "Fix 22868 - Let __traits(parameters) see past opApply delegates" was merged into stable:

- b070b2dbee6c474a80f1fe1f0eaeb6f717d3f051 by MoonlightSentinel:
  Fix 22868 - Let __traits(parameters) see past opApply delegates
  
  Ensure that `__traits(parameters)` consistently returns the parameters
  of the enclosing function and instead of the parameters of the
  `opApply` delegate (leaking an implementation detail).
  
  Also added a bunch of tests - the parts hidden by `version (Fixed)`
  fail due to another bug.

https://github.com/dlang/dmd/pull/13798
Comment 4 Dlang Bot 2022-03-27 02:24:34 UTC
dlang/dmd pull request #13892 "Merge stable into master" was merged into master:

- aa42a6bfdb80b5c56b911d329d7bedbfa3eeb318 by MoonlightSentinel:
  Fix 22868 - Let __traits(parameters) see past opApply delegates
  
  Ensure that `__traits(parameters)` consistently returns the parameters
  of the enclosing function and instead of the parameters of the
  `opApply` delegate (leaking an implementation detail).
  
  Also added a bunch of tests - the parts hidden by `version (Fixed)`
  fail due to another bug.

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