When a range violation occurs in an inlined function, the error message mentions the module which calls that function, not the module where it is defined. However, the line number corresponds to the file where the function is defined.
As this points to a wrong line of the source, the error can be very confusing the first time you encounter it. It surely looks like "debug capabilities broken".
-----caller.d-----
module caller;
import other;
// lines 3-5 contain no code
void main () {
fun (2);
}
-----
-----other.d-----
module other;
int [2] x;
void fun (int i) {
x[i]++;
}
-----
When we run "dmd caller.d other.d", we get the correct message:
[email protected](4): Range violation
However, add -inline, as in "dmd -inline caller.d other.d", and we see the error:
[email protected](4): Range violation
As you can see, line 4 of caller.d contains only a comment and so can not generate any errors.
This is reproducible for me on DMD 2.065.0 and DMD 2.066.0-b6 on Win32 and Win64.
Comment #1 by gassa — 2014-07-30T22:14:34Z
Created attachment 1375
module caller.d
Comment #2 by gassa — 2014-07-30T22:14:48Z
Created attachment 1376
module other.d
Comment #3 by razvan.nitu1305 — 2022-08-25T14:33:10Z
I cannot reproduce this with the latest compiler. Seems to have been fixed.