Fix incorrect lastAction generation when named parameters are used.

Fixes #3549