Bug 15032 – [REG2.068.1] coverage output is discreted around the calls to map(), canFind(), filter()

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2015-09-09T01:46:00Z
Last change time
2015-09-09T21:47:36Z
Assigned to
nobody
Creator
jiki

Comments

Comment #0 by jiki — 2015-09-09T01:46:56Z
This is a 2.068.1 issue, not 2.068.0. The coverage counts for the lines are ommited, around some range operations holding lambdas. Image: |bool isParentOf(in Symbol p, in Symbol sym, in Scope scx ) { | if (!p.hasBaseClass) | return false; | if (!sym) | return false; | auto names = sym.baseClasses; 0000000| if (names.canFind!((a,b)=>a==b)(p.name)) | return true; | auto list = names.map!toAggrSym; 0000000| if (list.canFind!((n, p)=>isParentOf(p, n.s, n.scx))(p)) | return true; | return false; |}
Comment #1 by jiki — 2015-09-09T01:49:10Z
A reduced test case: [command] dmd -cov mod_a.d mod_b.d [mod_a.d] import std.string; [mod_b.d] import std.algorithm; void main() { int[] range; // this line should be counted // but suppressed by this bug // canFind, map, filter, and so on range.canFind!((a,b)=>true)(0); // this line is counted(but wrong?) } [Output(mod_b.lst)] ...snipped... | int[] range; // this line should be counted | // but suppressed by this bug | // canFind, map, filter, and so on 0000000| range.canFind!((a,b)=>true)(0); // this line is counted(but wrong?) ...snipped... Note: The order of mod_a.d and mod_b.d affects.
Comment #2 by jiki — 2015-09-09T07:32:25Z
(In reply to jiki from comment #1) > [command] > dmd -cov mod_a.d mod_b.d Oops, please run 'mod_a' after the compile finished, of course.
Comment #3 by code — 2015-09-09T17:42:19Z
According to Digger this is caused by https://github.com/D-Programming-Language/dmd/pull/4944.
Comment #4 by code — 2015-09-09T21:47:36Z
The _Dmain functions ends up in the wrong object file (mod_a.o) b/c it's codegen is triggered from the nested find function. https://github.com/D-Programming-Language/dmd/blob/ea5d85af7abf0b1e36fd42a8d98fd692a765dea0/src/glue.c#L900 Therefor code for _Dmain is generated before the module's coverage symbol is setup (https://github.com/D-Programming-Language/dmd/blob/ea5d85af7abf0b1e36fd42a8d98fd692a765dea0/src/glue.c#L370) and incUsageElem will silently be skipped (https://github.com/D-Programming-Language/dmd/blob/ea5d85af7abf0b1e36fd42a8d98fd692a765dea0/src/toir.c#L62). This order related bug is also fixed by https://github.com/D-Programming-Language/dmd/pull/5058 which tries to emit nested functions after their parent function.