Error on using Compile[]


My code is below.

deltaX = 1/128; W=256; Mmax=40;  lPoly = ParallelTable[    LegendreP[     order, (-1.) + (deltaX/2.) + ((index - 1.)*deltaX)],  {order, 0, Mmax}, {index, 1, W}];  XPoly = Compile[{{index, _Integer}},     Block[{},      polyMatrix =       Table[lPoly[[m - n + 1, index]], {m, 0, Mmax}, {n, 0, m}];      polyMatrix], CompilationTarget -> "C",    RuntimeAttributes -> {Listable}, Parallelization -> True,     RuntimeOptions -> {"CatchMachineIntegerOverflow" -> False}]; 

If I run XPoly[1], it will return:

CompiledFunction::cfse :  Compiled expression {{1.},{-0.996094,1.},<<48>>,<<71>>} should be a machine-size real number. 

I have encountered this kinda error multiple times, sometimes it solved. But I dont know why.