View mode: basic / threaded / horizontal-split · Log in · Help
September 19, 2012
[Issue 8695] New: ParameterStorageClassTuple doesn't recognize 'in' parameters
http://d.puremagic.com/issues/show_bug.cgi?id=8695

          Summary: ParameterStorageClassTuple doesn't recognize 'in'
                   parameters
          Product: D
          Version: D2
         Platform: All
       OS/Version: All
           Status: NEW
         Severity: normal
         Priority: P2
        Component: Phobos
       AssignedTo: nobody@puremagic.com
       ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-09-19 07:40:04 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 14, 2013
[Issue 8695] ParameterStorageClassTuple doesn't recognize 'in' parameters
http://d.puremagic.com/issues/show_bug.cgi?id=8695


Mihail Strashun <m.strashun@gmail.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |m.strashun@gmail.com


--- Comment #1 from Mihail Strashun <m.strashun@gmail.com> 2013-01-14 04:56:39 PST ---
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)
-----------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 14, 2013
[Issue 8695] ParameterStorageClassTuple doesn't recognize 'in' parameters
http://d.puremagic.com/issues/show_bug.cgi?id=8695



--- Comment #2 from Mihail Strashun <m.strashun@gmail.com> 2013-01-14 05:11:11 PST ---
Hm, after some inspection it is not that related, I'll probably make a separate
bugzilla entry after scratching a fix.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 14, 2013
[Issue 8695] ParameterStorageClassTuple doesn't recognize 'in' parameters
http://d.puremagic.com/issues/show_bug.cgi?id=8695


Kenji Hara <k.hara.pg@gmail.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
         Component|Phobos                      |DMD


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-14 06:53:14 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 14, 2013
[Issue 8695] ParameterStorageClassTuple doesn't recognize 'in' parameters
http://d.puremagic.com/issues/show_bug.cgi?id=8695



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-14 07:34:33 PST ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 14, 2013
[Issue 8695] ParameterStorageClassTuple doesn't recognize 'in' parameters
http://d.puremagic.com/issues/show_bug.cgi?id=8695



--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-14 07:47:03 PST ---
(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_.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 14, 2013
[Issue 8695] ParameterStorageClassTuple doesn't recognize 'in' parameters
http://d.puremagic.com/issues/show_bug.cgi?id=8695



--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-14 07:52:49 PST ---
(In reply to comment #5)
> 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_.

So basically it was a no-op all this time. We've been telling newcomers to D
that 'in' means 'const scope' for the longest time.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home