Line numbers in programming languages

I am curious to find out has anyone seen a solution to the following problem?

a = b + c

Where b comes from file b.txt and c comes from file c.txt. Assuming that both b and c are generated via templates.

Assume there is a problem with c how can you point the error message to the right place?

If c.txt is generated or not is irrelevant, I guess.
The compiler will treat all input files equals and would report error found in c.txt line N.

This might be relevant:

Pablo Inostroza Valdera, Tijs van der Storm and Sebastian Erdweg. Tracing program transformations with string origins . In: ICMT , 2014


We face this issue at a fundamental level. The paper @jurgen.vinju linked to has interesting ideas. Just skimmed so far, but appreciate it.