Thread overview
[Issue 22865] __traits(compiles) affects inferrence of attributes
Mar 09, 2022
Basile-z
Mar 10, 2022
Basile-z
May 19, 2022
Dlang Bot
May 20, 2022
Dlang Bot
March 09, 2022
https://issues.dlang.org/show_bug.cgi?id=22865

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |b2.temp@gmx.com

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
patch

---
diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index 6eda68880..0c060fd0d 100644
--- a/src/dmd/expressionsem.d
+++ b/src/dmd/expressionsem.d
@@ -7629,6 +7629,8 @@ private extern (C++) final class
ExpressionSemanticVisitor : Visitor

         // Check for unsafe casts
         if (!sc.intypeof &&
+            !(sc.flags & SCOPE.compile && sc.flags & SCOPE.ctfe) &&
             !(sc.flags & SCOPE.debug_) &&
             !isSafeCast(ex, t1b, tob) &&
             (!sc.func && sc.stc & STC.safe || sc.func && sc.func.setUnsafe()))

---

--
March 10, 2022
https://issues.dlang.org/show_bug.cgi?id=22865

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
The basic problem is that the function scope is used to evaluate the enum value while we are more in a static scope that can see static things in parent scopes.

There is no system for this in the D frontend now. We can only known if
something static is evaluated (SCOPE.ctfe) or also if we are in a traits
compile (SCOPE.compile).

That fix is consequently not good but it does not break the test suite.

There is something very conceptual about semantics on if the cast should be allowed or not in "particular contexts".

--
May 19, 2022
https://issues.dlang.org/show_bug.cgi?id=22865

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #14144 "Fix issue 22865 - __traits(compiles) affects inferrence of attributes" fixing this issue:

- Fix issue 22865 - __traits(compiles) affects inferrence of attributes

https://github.com/dlang/dmd/pull/14144

--
May 20, 2022
https://issues.dlang.org/show_bug.cgi?id=22865

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14144 "Fix issue 22865 - __traits(compiles) affects inferrence of attributes" was merged into master:

- 5314bf7194aff2dd4c08234472bfd0829db05e8c by Dennis Korpel:
  Fix issue 22865 - __traits(compiles) affects inferrence of attributes

https://github.com/dlang/dmd/pull/14144

--