Bug 17503 – is-expression pattern in static if matches too many types

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-14T15:40:27Z
Last change time
2024-12-13T18:52:39Z
Assigned to
No Owner
Creator
Alexandre Bléron
Moved to GitHub: dmd#17798 →

Comments

Comment #0 by alex.bleron — 2017-06-14T15:40:27Z
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
Comment #1 by ag0aep6g — 2017-06-14T16:36:37Z
Reduced: ---- struct Vector(T, int N) {} static assert(!is(Vector!(int, 3) == Vector!(float, N), int N)); /* fails; should pass */ ----
Comment #2 by robert.schadek — 2024-12-13T18:52:39Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17798 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB