What version of Ignition are you currently running? I tested your code snippet on 8.1.23 and it works/outputs just fine without any errors. Could you share a screenshot testing your snippet in Script Console?
Could you also post the full stacktrace of the error? Where did you get this error? From the GW logs or the Designer console? other