Bug 24513 – `pure` can be used as `auto`

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-04-19T17:00:17Z
Last change time
2024-04-19T18:31:49Z
Keywords
accepts-invalid, diagnostic
Assigned to
No Owner
Creator
basile-z

Comments

Comment #0 by b2.temp — 2024-04-19T17:00:17Z
## summary `pure` can be used as `auto`, meaning that maybe it carries the same semantics ? ## test case ```d module runnable; pure p(string[] args) { pure a = args.length; return a - a; } int main(string[] args) { return cast(typeof(return)) p(args); } ``` ## notes wtf
Comment #1 by dkorpel — 2024-04-19T17:41:04Z
This is defined behavior: https://dlang.org/spec/function.html#auto-functions > An auto function is declared without a return type. Auto functions can use any valid StorageClass, not just auto.
Comment #2 by b2.temp — 2024-04-19T18:31:49Z
that's completly stupid. Nobody would accept that in phobos. Just imagine my friend, someone who makes a PR that is like ``` pure takeWhile(T)(auto ref T t); ``` any human being would open a review comment to say "why the heck dont you use auto" and then you have the complete ashole who comes and say > An auto function is declared without a return type. Auto functions can use any valid StorageClass, not just auto that's absurd.