digitalmars.D.bugs - [Issue 11303] New: IsExpression can not return the correct result about function & delegate
- d-bugmail puremagic.com (45/45) Oct 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11303
- d-bugmail puremagic.com (20/20) Oct 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11303
- d-bugmail puremagic.com (13/23) Oct 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11303
http://d.puremagic.com/issues/show_bug.cgi?id=11303 Summary: IsExpression can not return the correct result about function & delegate Product: D Version: D2 Platform: All OS/Version: Windows Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: 786325481 QQ.com Sorry for my poor English. I find that IsExpression can not return the correct result about function & delegate. Sample like that: unittest { static int test(int x) { return x * 2; } auto fn1 = &test; auto fn2 = (int x) { return x * 2; }; auto fn3 = (int x) { return x * 2; }; auto fn4 = (int x) => x * 2; auto fn5 = function (int x) => x * 2; auto fn6 = function (int x) { return x * 2; }; static assert(is(typeof(fn1) == function)); static assert(is(typeof(fn2) == function)); static assert(is(typeof(fn3) == function)); static assert(is(typeof(fn4) == function)); static assert(is(typeof(fn5) == function)); static assert(is(typeof(fn6) == function)); } IsExpression always return false, but the correct result is true. My environment : OS : Win8.1 Preview x64 Compiler: dmd2 2.063.2 & dmd2 2.064 beta IDE : Mono-D -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11303 Max Samukha <samukha voliacable.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |samukha voliacable.com Resolution| |INVALID PDT --- is(T == function) tests for function object type, not function pointer type. Many consider that an inconsistency, but that's the state of things. Your tests should be: static assert(is(typeof(*fn1) == function)); static assert(is(typeof(*fn2) == function)); static assert(is(typeof(*fn3) == function)); static assert(is(typeof(*fn4) == function)); static assert(is(typeof(*fn5) == function)); static assert(is(typeof(*fn6) == function)); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11303is(T == function) tests for function object type, not function pointer type. Many consider that an inconsistency, but that's the state of things. Your tests should be: static assert(is(typeof(*fn1) == function)); static assert(is(typeof(*fn2) == function)); static assert(is(typeof(*fn3) == function)); static assert(is(typeof(*fn4) == function)); static assert(is(typeof(*fn5) == function)); static assert(is(typeof(*fn6) == function));Ohhhhhhhh... I got it. Thanks for your reply. I am reading the TDPL.In the last paragraph of Chapter 5.6,there is a little example code.It likes that: auto f = (int i) {}; assert(is(f == function)); So I write the tests above. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 20 2013