Comment #0 by andrej.mitrovich — 2012-09-19T07:40:04Z
import std.traits;
void foo(const scope int x) { }
void bar(in int x) { }
void main()
{
alias ParameterStorageClass SC;
alias ParameterStorageClassTuple SCT;
static assert(SCT!foo[0] == SC.scope_);
static assert(SCT!bar[0] == SC.scope_);
}
Error: static assert (0u == cast(ParameterStorageClass)1u) is false
Since 'in' is equivalent to 'const scope' both asserts should pass.
Comment #1 by public — 2013-01-14T04:56:39Z
Somewhat similar, but for inout:
-----------------
import std.traits;
inout int func(inout int param)
{
return param;
}
void main()
{
alias stcs = ParameterStorageClassTuple!(typeof(func));
pragma(msg, stcs);
}
-----------------
/usr/local/include/dmd2/std/traits.d(97): Error: key 'g' not found in associative array ['a':cast(FunctionAttribute)1u,'b':cast(FunctionAttribute)2u,'c':cast(FunctionAttribute)4u,'d':cast(FunctionAttribute)8u,'e':cast(FunctionAttribute)16u,'f':cast(FunctionAttribute)32u]
/usr/local/include/dmd2/std/traits.d(458): called from here: demangleFunctionAttributes("NgiZi"c)
/usr/local/include/dmd2/std/traits.d(97): Error: key 'g' not found in associative array ['a':cast(FunctionAttribute)1u,'b':cast(FunctionAttribute)2u,'c':cast(FunctionAttribute)4u,'d':cast(FunctionAttribute)8u,'e':cast(FunctionAttribute)16u,'f':cast(FunctionAttribute)32u]
/usr/local/include/dmd2/std/traits.d(458): called from here: demangleFunctionAttributes("NgiZi"c)
/home/c565/c253.d(10): Error: template instance std.traits.ParameterStorageClassTuple!(inout int(inout(int) param)) error instantiating
demangleNextParameter!(demangleFunctionAttributes("NgiZi"c).rest)
-----------------
Comment #2 by public — 2013-01-14T05:11:11Z
Hm, after some inspection it is not that related, I'll probably make a separate bugzilla entry after scratching a fix.
Comment #3 by k.hara.pg — 2013-01-14T06:53:14Z
Comment#0 is a compiler issue.
In current, dmd converts 'in' storage class to 'const', not 'const scpope'.
But, I'm not sure which is correct, a wrong spec issue or compiler implementation bug.
Comment #1 is a Phobos issue.
ParameterStorageClassTuple and functionAttributes uses a private utility demangleFunctionAttributes, but it does not recognize inout function.
For the latter, I opened a separate bug 9317.
Comment #4 by andrej.mitrovich — 2013-01-14T07:34:33Z
(In reply to comment #3)
> Comment#0 is a compiler issue.
>
> In current, dmd converts 'in' storage class to 'const', not 'const scpope'.
> But, I'm not sure which is correct, a wrong spec issue or compiler
> implementation bug.
The spec page had not had 'in' documented for a long time, and we've discussed it many times where we said 'in' was 'const scope'. It's a compiler bug.
Comment #5 by k.hara.pg — 2013-01-14T07:47:03Z
(In reply to comment #4)
> (In reply to comment #3)
> > Comment#0 is a compiler issue.
> >
> > In current, dmd converts 'in' storage class to 'const', not 'const scpope'.
> > But, I'm not sure which is correct, a wrong spec issue or compiler
> > implementation bug.
>
> The spec page had not had 'in' documented for a long time, and we've discussed
> it many times where we said 'in' was 'const scope'. It's a compiler bug.
Even if it is correct, 'scope' storage class had not been discussed enough and its semantics had not been defined deeply.
In recent Walter says about 'scope': "nobody has gotten around to it."
https://github.com/D-Programming-Language/phobos/commit/ef0bed7d157afe5be5a69e17d5f30ffd309be527#commitcomment-2352989
So it seems to me that is yet not _defined_.
Comment #6 by andrej.mitrovich — 2013-01-14T07:52:49Z
*** Issue 8749 has been marked as a duplicate of this issue. ***
Comment #8 by razvan.nitu1305 — 2019-10-10T12:24:19Z
Spec: defined as scope const. However in has not yet been properly implemented so it's current implementation is equivalent to const. It is recommended to avoid using in until it is properly defined and implemented. Use scope const or const explicitly instead.
Closing as fixed.