digitalmars.D.bugs - [Issue 6385] New: isInputRange!(ubyte[2u]) is a failure when used in global scope
- d-bugmail puremagic.com (46/46) Jul 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6385
- d-bugmail puremagic.com (6/6) Jul 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6385
- d-bugmail puremagic.com (30/30) Aug 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6385
- d-bugmail puremagic.com (40/43) Aug 27 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6385
- d-bugmail puremagic.com (12/12) Sep 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6385
- d-bugmail puremagic.com (10/10) Sep 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6385
http://d.puremagic.com/issues/show_bug.cgi?id=6385
Summary: isInputRange!(ubyte[2u]) is a failure when used in
global scope
Product: D
Version: D2
Platform: Other
OS/Version: Linux
Status: NEW
Keywords: rejects-valid
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: schveiguy yahoo.com
11:18:02 PDT ---
The following code incorrectly produces an error:
import std.range;
pragma(msg, isInputRange!(ubyte[2u]).stringof);
Error: template instance std.array.front!(ubyte[2u]) incompatible arguments for
template instantiation
The code of isInputRange looks like this:
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
{
R r; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}()));
}
It was my impression that is(typeof(...)) should just return false on
compilation failure. I don't think isInputRange is incorrectly implemented.
The error is eliminated if you put the isInputRange call inside a function:
import std.range;
void main() {
pragma(msg, isInputRange!(ubyte[2u]).stringof);
}
outputs:
false
during compilation, and successfully compiles.
See related discussion here:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=28422
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6385 11:21:28 PDT --- BTW, this compiles on 2.051, fails on 2.052 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6385
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug yahoo.com.au
Reduced test case. It seems this bug is quite complicated, it requires two
semantic errors, plus uniform function call syntax, and a template constraint:
template template6385(T)
{
enum template6385 = false;
}
void bug6385(A)(A a) if (template6385!A)
{
this_is_an_error();
}
const bool bool6385 =
is(typeof(
{
ubyte[2] r;
this_is_another_error();
r.bug6385;
}()
));
The test case was accidentally fixed by commit:
https://github.com/D-Programming-Language/dmd/commit/dc83c
but I don't really understand why. It seems to be just luck.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6385
yebblies <yebblies gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |yebblies gmail.com
The test case was accidentally fixed by commit:
https://github.com/D-Programming-Language/dmd/commit/dc83c
but I don't really understand why. It seems to be just luck.
dc83c prevents dmd from re-evaluating the template constraint when the args
match an instance that already exists. Previously the constraint would be run
unless all template args had a spec. You can see this by changing 'void
bug6385(A)(A a) if (template6385!A)' to 'void bug6385(A : ubyte[2])(A a) if
(template6385!A)'.
Slightly smaller test case:
void templ6385(A)(A a) if ( { return false; }() )
{
this_is_an_error();
}
const bool bool6385 =
is(typeof(
{
this_is_another_error();
templ6385(1);
}()
));
void main() {}
Using an older commit, it seems that the cause is re-running semantic on
templ6385, as it's been added to the list of module members. This seems to be
similar to issue 4302 (caused by the fix to bug 4042) but missed by the patch
in 4302.
Changing
- if (!(sc->flags & SCOPEstaticif))
+ if (!(sc->flags & SCOPEstaticif) && !sc->intypeof)
from that patch seems to fix it, but I have no idea if there are any other
missing cases.
My guess at a correct solution is that
http://www.dsource.org/projects/dmd/changeset/477 is incorrect, and should
instead remove the TemplateInstance from the module's list of members.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 27 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6385
klickverbot <code klickverbot.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |code klickverbot.at
Resolution| |DUPLICATE
---
*** This issue has been marked as a duplicate of issue 6602 ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 05 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6385 --- I think the problem described above didn't occur if the isInputRange instantiation is inside a function, because then the instance was added to the global list later, during semantic3, and TemplateInstance::semantic3 immediately exists if this.error is set, whereas TemplateInstance::semantic doesn't bail out early. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 05 2011









d-bugmail puremagic.com 