[Issue 8339] New: is(typeof(...)) is reporting true when it's false due to nested function error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 2 22:43:25 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8339
Summary: is(typeof(...)) is reporting true when it's false due
to nested function error
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: blocker
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-07-02 22:43:22 PDT ---
This code fails to compile:
import std.algorithm;
private bool testEmptyInit(R)()
{
static if(is(typeof({R range;})))
{
R range;
return range.empty;
}
else
return false;
}
void main()
{
testEmptyInit!(typeof(filter!"true"([0, 1, 2, 3])));
}
giving this error
h.d(7): Error: function std.algorithm.filter!("true").filter!(int[]).filter is
a nested function and cannot be accessed from
h.testEmptyInit!(FilteredRange).testEmptyInit
So, the compiler thinks that is(typeof({R range;})) is true for the type of
filter's result and then it gives an error saying that it's invalid to use it,
meaning that it's _not_ valid and therefore is(typeof({R range;})) should be
false.
If bug# 5941 were fixed, this wouldn't be as big an issue (though the fact that
you can get an error for using a construct when the test for using it passes is
definitely a bug regardless), but as long as bug# 5941 exists, this is a major
blocker for being able to create a template to check for whether the init value
of a range type is empty or not.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list