fix optional argument scanning bug
(cherry picked from commit 2a90afe7e9a1b3afe00c286971700d9363c44842)