Thread overview
[Issue 13478] [REG2.066] Templates not emitted when also referenced in speculative contexts
Sep 15, 2014
David Nadlinger
Sep 15, 2014
David Nadlinger
Sep 15, 2014
David Nadlinger
Sep 15, 2014
Vladimir Panteleev
Sep 15, 2014
Kenji Hara
Sep 15, 2014
David Nadlinger
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

--- Comment #1 from David Nadlinger <code@klickverbot.at> ---
(Pull request incoming.)

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

--- Comment #2 from David Nadlinger <code@klickverbot.at> ---
This seems to have been fixed on master, and in a different way than I would have tried. Need Kenji to chime in here.

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

David Nadlinger <code@klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|nobody@puremagic.com        |k.hara.pg@gmail.com

--- Comment #3 from David Nadlinger <code@klickverbot.at> ---
Explanation of what happens: During the inline scan semantic, the foo!int TemplateInstance in 'c' overwrites the instantiatingModule of the one in 'a', even though it is speculative. Patch, but seems to not occur any longer on master for a different reason:

diff --git a/src/template.c b/src/template.c
index c230f62..45010ec 100644
--- a/src/template.c
+++ b/src/template.c
@@ -6259,7 +6259,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions
*fargs)
 #if LOG
             printf("\tit's a match with instance %p, %d\n", inst,
inst->semanticRun);
 #endif
-            if (!inst->instantiatingModule ||
inst->instantiatingModule->isRoot())
+            if (!speculative && (!inst->instantiatingModule ||
inst->instantiatingModule->isRoot()))
                 inst->instantiatingModule = mi;
             errors = inst->errors;
             return;

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com

--- Comment #4 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Introduced in https://github.com/D-Programming-Language/dmd/pull/2561

Fixed by https://github.com/D-Programming-Language/dmd/pull/3948

The fix introduced a regression: issue 13479

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to David Nadlinger from comment #3)
> Explanation of what happens: During the inline scan semantic, the foo!int TemplateInstance in 'c' overwrites the instantiatingModule of the one in 'a', even though it is speculative.

-inline will invoke additional semantic3() phase, and it will modify "instantiation graph" expressed by TemplateInstance::tinst and instantiatingModule.

It's the issue that I tried to fix in https://github.com/D-Programming-Language/dmd/pull/3948.


> Patch, but seems to not occur any longer
> on master for a different reason:
> 
> diff --git a/src/template.c b/src/template.c
> index c230f62..45010ec 100644
> --- a/src/template.c
> +++ b/src/template.c
> @@ -6259,7 +6259,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions
> *fargs)
>  #if LOG
>              printf("\tit's a match with instance %p, %d\n", inst,
> inst->semanticRun);
>  #endif
> -            if (!inst->instantiatingModule ||
> inst->instantiatingModule->isRoot())
> +            if (!speculative && (!inst->instantiatingModule ||
> inst->instantiatingModule->isRoot()))
>                  inst->instantiatingModule = mi;
>              errors = inst->errors;
>              return;

Patch looks good. Even if a new instantiation (== 'this') is in non-root
module, when it's a speculatively instantiation (this->speculative == true), it
should not modify the instantiation graph (== inst->instantiatingModule).

Could you please open a Pull Request for 2.066 branch?

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

David Nadlinger <code@klickverbot.at> changed:

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

--- Comment #6 from David Nadlinger <code@klickverbot.at> ---
(In reply to Kenji Hara from comment #5)
> Could you please open a Pull Request for 2.066 branch?

Done: https://github.com/D-Programming-Language/dmd/pull/3993

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to 2.066 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/972c90fddc053cc0e4560077dce4f1753269fdef
Fix Issue 13478 - [REG2.066] Templates not emitted when also referenced in
speculative contexts

On master, this has already been fixed as a by-product of Kenji's minst/… rewrite of the instantiation tracking logic.

https://github.com/D-Programming-Language/dmd/commit/0acbd549026041920a6b28cedca4a4e2e91a915b Merge pull request #3993 from klickverbot/2.066

Fix Issue 13478 - [REG2.066] Templates not emitted when also referenced in speculative contexts

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

github-bugzilla@puremagic.com changed:

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

--
September 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13478

--- Comment #8 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c3331644a325cb240d27d0915a305829a353defd Add test case for issue 13478.

The issue was a 2.066 regression that has been fixed differently on master in the meantime. This adds the test case from the 2.066 branch commit 972c90f.

https://github.com/D-Programming-Language/dmd/commit/5391f3c4c7efd69b219bd1810ec16c2af9f54256 Merge pull request #3996 from klickverbot/issue-13478-tests

Add test case for issue 13478.

--
February 19, 2015
https://issues.dlang.org/show_bug.cgi?id=13478

--- Comment #9 from github-bugzilla@puremagic.com ---
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c3331644a325cb240d27d0915a305829a353defd Add test case for issue 13478.

https://github.com/D-Programming-Language/dmd/commit/5391f3c4c7efd69b219bd1810ec16c2af9f54256 Merge pull request #3996 from klickverbot/issue-13478-tests

--