| Thread overview | |||||
|---|---|---|---|---|---|
|
April 01, 2009 is(this == bug) ??? | ||||
|---|---|---|---|---|
| ||||
void doStuff(T)(T arg)
if(is(typeof(arg))) {
}
void main() {
doStuff(1);
}
Results:
test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) does not match any
function template declaration|
test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) cannot deduce
template function from argument types !()(int)|
This code does not compile with 2.027, 2.026, or 2.016 (the first version that had constraints). If it is, in fact, a bug, I find it amazing that it's apparently taken over half a year for anyone to notice. (Searching bugzilla for "constraints" yields nothing.) If it's not a bug, then I can't for the life of me figure out why it won't compile.
| ||||
April 01, 2009 Re: is(this == bug) ??? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to dsimcha | == Quote from dsimcha (dsimcha@yahoo.com)'s article
> void doStuff(T)(T arg)
> if(is(typeof(arg))) {
> }
> void main() {
> doStuff(1);
> }
> Results:
> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) does not match any
> function template declaration|
> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) cannot deduce
> template function from argument types !()(int)|
> This code does not compile with 2.027, 2.026, or 2.016 (the first version that
> had constraints). If it is, in fact, a bug, I find it amazing that it's
> apparently taken over half a year for anyone to notice. (Searching bugzilla
> for "constraints" yields nothing.) If it's not a bug, then I can't for the
> life of me figure out why it won't compile.
(Slapping forehead)
Never mind. After struggling with this for an hour, I realized that arg is not in scope when the constraint is evaluated.
| |||
April 02, 2009 Re: is(this == bug) ??? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to dsimcha | dsimcha wrote:
> == Quote from dsimcha (dsimcha@yahoo.com)'s article
>> void doStuff(T)(T arg)
>> if(is(typeof(arg))) {
>> }
>> void main() {
>> doStuff(1);
>> }
>> Results:
>> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) does not match any
>> function template declaration|
>> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) cannot deduce
>> template function from argument types !()(int)|
>> This code does not compile with 2.027, 2.026, or 2.016 (the first version that
>> had constraints). If it is, in fact, a bug, I find it amazing that it's
>> apparently taken over half a year for anyone to notice. (Searching bugzilla
>> for "constraints" yields nothing.) If it's not a bug, then I can't for the
>> life of me figure out why it won't compile.
>
> (Slapping forehead)
>
> Never mind. After struggling with this for an hour, I realized that arg is not in
> scope when the constraint is evaluated.
No, no, always mind. The parameter name should be visible in the if-constraint of a template. Please file a bug.
Also the parameter names should be visible in the return type (if it uses e.g. sizeof or typeof). I think I filed that.
Andrei
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply