Error in derivatives of perfect foresight models with leaded or lagged exogenous variables

A perfect foresight model with leads and lags in exogenous variables produces wrong derivative file dynamic_g1.m such as:

...
g1 = zeros(6, 12);
g1(1,8)=(-params(1));
g1(1,8)=1;
...

Here is test_0.mod: test_o.mod

The issue occurs in 4.6 and in the unstable version.

Edited by MichelJuillard