D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2128 - Template function argument binding is too restrictive wrt qualifiers
Summary: Template function argument binding is too restrictive wrt qualifiers
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 enhancement
Assignee: Walter Bright
URL:
Keywords:
: 2594 (view as issue list)
Depends on:
Blocks:
 
Reported: 2008-05-24 12:10 UTC by Andrei Alexandrescu
Modified: 2018-05-15 14:00 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2008-05-24 12:10:39 UTC
This code won't compile:

void foo(Idx)(Idx a, Idx b) {}

void main(string[] args)
{
    uint x;
    invariant uint y;
    foo(x, y);
}

I think it should.
Comment 1 Bruno Medeiros 2008-05-28 16:18:52 UTC
What would typeof(Idx) be in that instantiation? const(uint)?
Comment 2 Walter Bright 2008-06-15 20:43:04 UTC
I agree with Bruno, I don't know what rule to use to accept this.
Comment 3 Simen Kjaeraas 2011-03-15 10:21:31 UTC
*** Issue 2594 has been marked as a duplicate of this issue. ***
Comment 4 Don 2012-11-12 07:35:28 UTC
Changing to enhancement.
Comment 5 Dmitry Olshansky 2018-05-15 14:00:58 UTC
Works with s/invariant/immutable/:


void foo(Idx)(Idx a, Idx b) {}

void main(string[] args)
{
    uint x;
    immutable uint y;
    foo(x, y);
}


Compiles just fine.