www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22480] New: Lack of template instantiation memoization for


          Issue ID: 22480
           Summary: Lack of template instantiation memoization for failed
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: eyal weka.io

Example program:

  struct T(uint x) {
      pragma(msg, "Instantiated at ", x);
      static assert(x == 0);

  static assert(is(T!0));
  static assert(is(T!0));
  static assert(!is(T!1));
  static assert(!is(T!1));         // redoes all the work :-(


  Instantiated at 0u
  Instantiated at 1u
  Instantiated at 1u

Sometimes, detecting an error in template instantiation can be costly.

If the compiler memoized not only template instantiation successes but also
failures, it can save compilation time and improve output when pragma(msg, ...)
are involved.

Nov 04 2021