[Issue 17503] New: is-expression pattern in static if matches too many types
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jun 14 08:40:27 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17503
Issue ID: 17503
Summary: is-expression pattern in static if matches too many
types
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: alex.bleron at gmail.com
In the following example, the static if branch is taken for both T=Vector!(int,
N) and T=Vector!(float, N), while it should only match Vector!(float,N)
-----------------------------------------------------
struct Vector(T, int N)
{}
alias vec3 = Vector!(float, 3);
alias ivec3 = Vector!(int, 3);
struct Test(T)
{
void test()
{
static if (is(T == Vector!(float, N), int N)) {
pragma(msg, typeof(this).stringof, "..");
}
}
}
alias TestVec3 = Test!vec3;
alias TestIVec3 = Test!ivec3;
void main()
{
TestVec3 tv3;
TestIVec3 tiv3;
}
-----------------------------------------------------
Compiler output:
Test!(Vector!(float, 3))..
Test!(Vector!(int, 3))..
-----------------------------------------------------
Expected Compiler output:
Test!(Vector!(float, 3))..
-----------------------------------------------------
Link:
http://asm.dlang.org/#compilers:!((compiler:dmd2071,options:'',sourcez:FAZwLgTgrgxmAEA1ApnA9hAFAFQDTwEsA7BAOQEp5gBvAX2GAEMAbAxkeAN1QGZ4BeJKjAYAhJgBmzNIzD4e5ANxNW7Qtxh9BKdBHHE58BctCRYCbMnA5yNYPC5oCAE3hgrYTLYfV7D%2BOCyBDCEEvCYBCA4AtrCYpLSsvgU%2BAbwFJS%2B/v4ADhCMAOYAtoyYRSAF%2BGAAnjnIaBKYYAAWkeQAdOAQxAUN%2BABE7e39SlTZ9A709CpsHJbgOlrw82CiGjzKLLPLHgCSiwI74KIE6yacTq4lxF52DisHYJwbfiv7vG6nL7RAAAA%3D%3D)),filterAsm:(binary:!t),version:3
--
More information about the Digitalmars-d-bugs
mailing list