Bug 21554 – Invalid assignment expression yields valid type in is(typeof)-expression

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-01-18T00:09:28Z
Last change time
2024-12-13T19:14:03Z
Assigned to
No Owner
Creator
kinke
Moved to GitHub: dmd#19854 →

Comments

Comment #0 by kinke — 2021-01-18T00:09:28Z
class MyClass { T opCall(T)(T p) { return p; } } void emplaceRef(T, Args...)(ref T chunk, auto ref Args args) { static assert(!__traits(compiles, chunk = T(args))); // the following fails: `!is(MyClass)` is false static assert(!is(typeof(chunk = T(args)))); } int foo() { MyClass c; emplaceRef(c, new MyClass); }
Comment #1 by boris2.9 — 2021-01-18T02:34:30Z
Is not this intended? typeof doesn't evaluate the expression. I remember seeing phobos depending on this exact behavior. class A { int fun(); } static assert(is(typeof(A.fun()) == int)); static assert(!__traits(compiles, A.fun())); // Error: need this for fun of type int()
Comment #2 by kinke — 2021-01-18T11:10:05Z
I'm not sure but I very much doubt it. It accounted for a bug in druntime: https://github.com/dlang/druntime/pull/3332
Comment #3 by robert.schadek — 2024-12-13T19:14:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19854 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB