Writing task inside a function

In reply to Arshia:

SystemVerilog does not allow functions to have blocking statements, and explicitly;

A function shall not enable tasks regardless of whether those tasks contain time-controlling
statements.

This is a tool bug, If you used your function with a delay in an expression, it would not make any sense.