D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16014 - Concatenated strings don't work in deprecation messages on module statements
Summary: Concatenated strings don't work in deprecation messages on module statements
Status: RESOLVED DUPLICATE of issue 12954
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2016-05-11 00:23 UTC by Jack Stouffer
Modified: 2020-05-18 12:43 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jack Stouffer 2016-05-11 00:23:39 UTC
This fails to compile

------
deprecated(""~"") module a;
------
Comment 1 Kenji Hara 2016-05-11 14:41:19 UTC
Although the OP code is legitimate from the D grammar spec, there's not yet proper definition/implementation for the semantic analysis.

I'm not sure how compiler should behave with:

deprecated(a.foo() ~ a.bar()) module a;

string foo() { /* some CTFEable code 1 */ }
string bar() { /* some CTFEable code 2 */ }

----

Note that if we replace module with struct:

deprecated(S.foo) struct S   // line 1
{
    static foo() { return "hello"; }
}
alias P = S*;  // line 5


Current compiler prints:

test.d(1): Deprecation: struct test.S is deprecated
test.d(5): Deprecation: struct test.S is deprecated - hello

The use of S in custom message expression exposes incompletion of semantic analysis process. It's bad behavior.
Comment 2 Jack Stouffer 2016-05-11 14:45:16 UTC
It could at least be made to work with string literals and manifest constants, right?
Comment 3 Kenji Hara 2016-05-11 15:14:58 UTC
(In reply to Jack Stouffer from comment #2)
> It could at least be made to work with string literals and manifest
> constants, right?

I think it's not good to implement vulnerable behavior. It would just bloat compiler maintenance cost.

By the way, do you have a concrete situation you would like to use contatenation, manifest constant, or other compile time constructed message for module deprecation?
Comment 4 jiki 2016-05-11 15:41:45 UTC
One could simply put pragma message in that module.

module a;

pragma(msg, __FILE__,"(",__LINE__,"): this module is deprecated");
Comment 5 Jack Stouffer 2016-05-12 11:20:12 UTC
(In reply to Kenji Hara from comment #3)
> (In reply to Jack Stouffer from comment #2)
> > It could at least be made to work with string literals and manifest
> > constants, right?
> 
> I think it's not good to implement vulnerable behavior. It would just bloat
> compiler maintenance cost.

But this is already the behavior for everything but module declarations:

-----
struct A
{
    deprecated(""~"") int a;
}

void main()
{
    A s;
    s.a = 4;
}
-----

$ dmd -run test.d

Deprecation: variable test.A.a is deprecated -

> By the way, do you have a concrete situation you would like to use
> contatenation, manifest constant, or other compile time constructed message
> for module deprecation?

Yes, in Phobos we are trying to enforce Phobos style guides via dscanner, and we need this in order to make every line in Phobos less than 120 characters.
Comment 6 Mathias LANG 2020-05-18 12:43:34 UTC
Sometime I look at the timing, and I think we're doing a really bad job at marketing our awesome features. The fix for this was merged in February 2016, so 3 months before this bug report was open. Fixed by: https://github.com/dlang/dmd/pull/5302
Marking as duplicate of the original issue.

*** This issue has been marked as a duplicate of issue 12954 ***