Bug 19439 – Make __traits(getAliasThis) return empty tuple for non-aggregate types

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2018-11-27T05:52:11Z
Last change time
2018-12-30T16:07:10Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2018-11-27T05:52:11Z
It is frequently necessary to verify that aliasing is not occurring. Checking that the result of __traits(getAliasThis) has length 0 is a concise and natural way of doing this. Unfortunately it is currently disallowed to `getAliasThis` a non-aggregate type. Returning an empty tuple instead of raising a compile-time error would also be convenient for using `getAliasThis` in type-generic code. It should not make DMD slower to change this behavior: not raising an error slightly simplifies the logic.
Comment #1 by github-bugzilla — 2018-12-07T10:39:49Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/7d3a7631b59501ae9ae85ec9b7a43529d50b9dd9 Fix Issue 19439 - Make __traits(getAliasThis) return empty tuple for non-aggregate types
Comment #2 by github-bugzilla — 2018-12-30T16:07:10Z
Commit pushed to master at https://github.com/dlang/dlang.org https://github.com/dlang/dlang.org/commit/8e32471a33ebf1f445fb377021308d7ed00d1f35 Merge pull request #2517 from n8sh/issue-19439 Update getAliasThis documentation per issue 19439 merged-on-behalf-of: Petar Kirov <[email protected]>