Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 18, 2015 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |spec CC| |thecybershadow@gmail.com -- |
June 09, 2015 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 Andrei Alexandrescu <andrei@erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |D2 -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 Alexander <ismailsiege@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ismailsiege@gmail.com --- Comment #2 from Alexander <ismailsiege@gmail.com> --- void testf(){} void main() { static assert(!is(testf == function)); // OK static assert(is(typeof(testf) == function)); // OK static assert(is(typeof( (){} ) == delegate)); // fails } But "is" doesn't work with function literals themselves in the first place, it is intended to check whether type is equivalent to function pointer or not. Same goes for: static if (is(typeof((int, float){}) P == function)) pragma(msg, P); else static assert(0); // fails -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 --- Comment #3 from Alexander <ismailsiege@gmail.com> --- static assert(is(typeof( (){} ) == function)); // fails as well This issue doesn't allow to get lambda parameter types tuple, and this blocks my development. I'll try to have a look at the dmd source. -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 Alexander <ismailsiege@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 Alexander <ismailsiege@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |WONTFIX --- Comment #4 from Alexander <ismailsiege@gmail.com> --- Ok, I'll agree with Maxim, it's probably as it should be. template isFunctionPointerType(T: FT*, FT) { enum isFunctionPointerType = is(FT == function); } unittest { auto p = (){}; static assert(isFunctionPointerType!(typeof(p))); } -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 ZombineDev <petar.p.kirov@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |petar.p.kirov@gmail.com --- Comment #5 from ZombineDev <petar.p.kirov@gmail.com> --- (In reply to Alexander from comment #3) > static assert(is(typeof( (){} ) == function)); // fails as well > > This issue doesn't allow to get lambda parameter types tuple, and this blocks my development. I'll try to have a look at the dmd source. Is the blocking issue that in code similar to the following, there's an error on line 11: --- import std.traits; pragma (msg, ReturnType!( (){} )); // void pragma (msg, Parameters!( (){} )); // () pragma (msg, ReturnType!( (int x, double y) => "test" )); // string pragma (msg, Parameters!( (int x, double y) => "test" )); // (int, double) void lambdaTypeWithParameter(alias lambda, Param)(Param p) { pragma (msg, Parameters!(lambda)); // line 11 - doesn't compile alias RT = typeof(lambda(p)); pragma (msg, RT); // line 15 } void main() { lambdaTypeWithParameter!(x => "test2")(true); // line 15 -> string lambdaTypeWithParameter!(x => x)(2); // line 15 -> int lambdaTypeWithParameter!(x => 3.0 * x)(2); // line 15 -> double } --- ? If that's the case, the error is expected since the lambda in that context is polymorphic - an un-instantiated function template meaning that its parameters are not bound to a specific type. -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 ZombineDev <petar.p.kirov@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WONTFIX |--- --- Comment #6 from ZombineDev <petar.p.kirov@gmail.com> --- Let's keep the bug open until the language authors take an authoritative decision to keep or fix this issue. -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 --- Comment #7 from anonymous4 <dfj1esp02@sneakemail.com> --- How it works now: --- void f(){} static assert(is(typeof(f)==function)); static assert(is(typeof(&f)==function)); --- line 3: Error: static assert (is(void function() == function)) is false Looks like function pointer is not recognized as `function` by `is` expression. -- |
June 23, 2017 [Issue 11012] [TDPL] is(typeof(f) == function) fails with some functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11012 anonymous4 <dfj1esp02@sneakemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://dlang.org/spec/expr | |ession.html#IsExpression --- Comment #8 from anonymous4 <dfj1esp02@sneakemail.com> --- static assert(is(typeof(&f)==delegate)); fails too, and spec doesn't specify how `is` expression works, which is definitely a bug. -- |
Copyright © 1999-2021 by the D Language Foundation