[JIRA] (JENKINS-62064) CPS transformed assignment expressions do not return their result

3 views
Skip to first unread message

dnusbaum@cloudbees.com (JIRA)

unread,
Apr 27, 2020, 11:43:04 AM4/27/20
to jenkinsc...@googlegroups.com
Devin Nusbaum created an issue
 
Jenkins / Bug JENKINS-62064
CPS transformed assignment expressions do not return their result
Issue Type: Bug Bug
Assignee: Unassigned
Components: workflow-cps-plugin
Created: 2020-04-27 15:42
Environment: workflow-cps 2.80
Labels: pipeline groovy
Priority: Minor Minor
Reporter: Devin Nusbaum

As described in https://stackoverflow.com/questions/61420959/jenkins-interpretation-of-multiple-object-declarations-on-one-line, CPS-transformed assignment expressions do not return their result. Here is an example:

def a = b = c = 1 

In a Pipeline, after executing that expression a == null, b == null, and c == 1.

In regular Groovy, after executing that expression, a, b, and c, are all equal to 1.

Here is a (failing) workflow-cps test case (for CpsFlowDefinition2Test) that demonstrates the bug:

@Test public void assignmentExprsReturnRhs() throws Exception {
    WorkflowJob p = jenkins.createProject(WorkflowJob.class);
    p.setDefinition(new CpsFlowDefinition(
            "def a = b = c = 1\n" +
            "println(/a == ${a}/)\n" +
            "println(/b == ${b}/)\n" +
            "println(/c == ${c}/)\n", true));
    WorkflowRun b = jenkins.buildAndAssertSuccess(p);
    jenkins.assertLogContains("a == 1", b);
    jenkins.assertLogContains("b == 1", b);
    jenkins.assertLogContains("c == 1", b);
} 

I think the relevant code is AssignmentBlock in groovy-cps. In particular, I think that assignAndDone needs to create a new continuation to pass to lhs.set that calls k.receive(rhs) internally.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages