jenkinsci / groovy-sandbox

(Deprecated) Compile-time transformer to run Groovy code in a restrictive sandbox
MIT License
122 stars 60 forks source link

[FIXED JENKINS-46191] Do not cast empty declarations. #39

Closed abayer closed 7 years ago

abayer commented 7 years ago

JENKINS-46191

Before this change, "String foo;" would result in

BUG! exception in phase 'class generation' in source unit 'Script1.groovy' Error while popping argument from operand stack tracker in class Script1 method java.lang.Object run().

This is because in that scenario, the right hand side is an EmptyExpression, which ends up breaking all the things when you try to cast it to something else. So we shouldn't be trying to do a cast at all here, and instead just transform the declaration expression (which actually may not be needed itself, but better safe than sorry to still transform the left hand side's variable expression, which is basically all that will happen).

cc @reviewbybees

ghost commented 7 years ago

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.