Bug 9317 – ParameterStorageClassTuple reports errors for inout function
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-14T06:47:00Z
Last change time
2013-01-15T15:24:38Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2013-01-14T06:47:34Z
Separation from: http://d.puremagic.com/issues/show_bug.cgi?id=8695#c1
-----------------
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 #1 by public — 2013-01-14T06:51:04Z
Quick investigation: this is actually more related to demangleXXX family of functions in std.traits
Their type system awareness seems a bit out of date :)
Comment #2 by k.hara.pg — 2013-01-14T07:02:54Z
(In reply to comment #1)
> Quick investigation: this is actually more related to demangleXXX family of
> functions in std.traits
> Their type system awareness seems a bit out of date :)
As far as I see, demangleParameterStorageClass has no problem.
In current, the set of valid parameter storage classes is (scope, out ref, lazy).
And `inout` is always treated as a type qualifier, so is not contained the set.
On the other hand, demangleFunctionAttributes has the problem that just reported here.
(In reply to comment #2)
> In current, the set of valid parameter storage classes is (scope, out ref,
> lazy).
> And `inout` is always treated as a type qualifier, so is not contained the set.
Is there any single place on dlang.org or in TDPL where this can be read? I am struggling to find proper classification of D type system since the very start of work on fullyQualifiedTypeName.
Comment #5 by k.hara.pg — 2013-01-14T07:35:48Z
(In reply to comment #4)
> (In reply to comment #2)
> > In current, the set of valid parameter storage classes is (scope, out ref,
> > lazy).
> > And `inout` is always treated as a type qualifier, so is not contained the set.
>
> Is there any single place on dlang.org or in TDPL where this can be read? I am
> struggling to find proper classification of D type system since the very start
> of work on fullyQualifiedTypeName.
Mostly complete thing is here.
http://dlang.org/function#parameters
- const, immutable, share, and inout implicitly qualify the parameter type.
That means, foo(const T param) is implicitly translated to foo(const(T) param).
After that, they will not remain as actual 'storage class'.
- The description >>'in' equivalent to 'const scope'<< is not correct.
With current compiler implementation, 'in' is just treated as 'const'.
So it's treated as a part of type, and will not remain as actual 'storage class'
- Remaining four, 'ref', 'scope', 'lazy', and 'out' will have actual meanings as 'storage class'.
Comment #6 by github-bugzilla — 2013-01-15T15:24:38Z