Either way, the attribute certainly looks like it's part of the declaration, I think any reasoning programmer would assume that it is. It's only a DMD implementation detail that says otherwise, and it's not particularly intuitive to a programmer.
It's not a dmd implementation detail. It is part of current D language design. dmd works as well. No bug there, so this is definitely an enhancement.
But I can agree that is a little not good from human sense. I know a related issue.
struct S {
immutable int foo() {} // immutable is prefix attribute (==storage class)
}
In above, `immutable` would be applied to the declaration `foo`, not its return type `int`.
But, changing semantics would break much existing code. Your enhancement belongs same area. We need to get agreement of D programmers first.