payload: {"action":"created","issue":{"url":"https://api.github.com/repos/spockframework/spock/issues/880","repository_url":"https://api.github.com/repos/spockframework/spock","labels_url":"https://api.github.com/repos/spockframework/spock/issues/880/labels{/name}","comments_url":"https://api.github.com/repos/spockframework/spock/issues/880/comments","events_url":"https://api.github.com/repos/spockframework/spock/issues/880/events","html_url":"https://github.com/spockframework/spock/issues/880","id":352835904,"node_id":"MDU6SXNzdWUzNTI4MzU5MDQ=","number":880,"title":"Parameter type is inferred wrong when local variable with same name is present in unrelated method","user":{"login":"lptr","id":495366,"node_id":"MDQ6VXNlcjQ5NTM2Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/495366?v=4","gravatar_id":"","url":"https://api.github.com/users/lptr","html_url":"https://github.com/lptr","followers_url":"https://api.github.com/users/lptr/followers","following_url":"https://api.github.com/users/lptr/following{/other_user}","gists_url":"https://api.github.com/users/lptr/gists{/gist_id}","starred_url":"https://api.github.com/users/lptr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lptr/subscriptions","organizations_url":"https://api.github.com/users/lptr/orgs","repos_url":"https://api.github.com/users/lptr/repos","events_url":"https://api.github.com/users/lptr/events{/privacy}","received_events_url":"https://api.github.com/users/lptr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-08-22T07:35:53Z","updated_at":"2019-05-18T11:14:13Z","closed_at":null,"author_association":"NONE","body":"# Issue description\r\n\r\nUsing a `where:` clause, the type of a parameter is inferred incorrectly from the type of a local variable declared in an unrelated method when using Groovy 2.5. The issue does not occur with Groovy 2.4\r\n\r\n# How to reproduce\r\n\r\nConsider the following code:\r\n\r\n```groovy\r\nimport spock.lang.Specification\r\nimport spock.lang.Unroll\r\n\r\n@Unroll\r\nclass MyTest extends Specification {\r\n    def \"#a <=> #b: #result\"() {\r\n        expect:\r\n        Math.signum(a <=> b) == result\r\n\r\n        where:\r\n        a            | b            | result\r\n        \"abcdef12\"   | \"abcdef12\"   | 0\r\n    }\r\n\r\n    private double[] someOtherMethod() {\r\n        double[] result = new double[0]\r\n        return result\r\n    }\r\n}\r\n```\r\n\r\nThis works fine when using Groovy 2.4, but fails when using Groovy 2.5 – both with Spock `1.0-groovy-2.4` and `1.2-RC1-groovy-2.5`:\r\n\r\n```text\r\nabcdef12 <=> abcdef12: [0.0]\r\nCondition not satisfied:\r\n\r\nMath.signum(a <=> b) == result\r\n     |      | |   |  |  |\r\n     0.0    | 0   |  |  [0.0]\r\n            |     |  false\r\n            |     abcdef12\r\n            abcdef12\r\n\r\n\tat MyTest.#a <=> #b: #result(MyTest.groovy:8)\r\n```\r\n\r\nNotice that result's value is printed as `[0.0]`, which matches the type of the local variable `result` defined in `someOtherMethod()`. If that method is removed, or the `result` parameter in the test is renamed, the test works as expected.\r\n\r\n## Link to a gist or similar (optional)\r\n\r\nHere's a full build to reproduce the problem: https://github.com/lptr/spock-groovy-bug\r\n\r\nJust run `./gradlew test`\r\n\r\n# Additional Environment information\r\n\r\nGradle 4.9, Groovy 2.5.2, Spock 1.2-RC1"},"comment":{"url":"https://api.github.com/repos/spockframework/spock/issues/comments/493668968","html_url":"https://github.com/spockframework/spock/issues/880#issuecomment-493668968","issue_url":"https://api.github.com/repos/spockframework/spock/issues/880","id":493668968,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5MzY2ODk2OA==","user":{"login":"paulk-asert","id":280016,"node_id":"MDQ6VXNlcjI4MDAxNg==","avatar_url":"https://avatars3.githubusercontent.com/u/280016?v=4","gravatar_id":"","url":"https://api.github.com/users/paulk-asert","html_url":"https://github.com/paulk-asert","followers_url":"https://api.github.com/users/paulk-asert/followers","following_url":"https://api.github.com/users/paulk-asert/following{/other_user}","gists_url":"https://api.github.com/users/paulk-asert/gists{/gist_id}","starred_url":"https://api.github.com/users/paulk-asert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulk-asert/subscriptions","organizations_url":"https://api.github.com/users/paulk-asert/orgs","repos_url":"https://api.github.com/users/paulk-asert/repos","events_url":"https://api.github.com/users/paulk-asert/events{/privacy}","received_events_url":"https://api.github.com/users/paulk-asert/received_events","type":"User","site_admin":false},"created_at":"2019-05-18T11:14:13Z","updated_at":"2019-05-18T11:14:13Z","author_association":"CONTRIBUTOR","body":"Do you know if there is a reason why in the statement below, the `result` VariableExpression has the accessedVariable set to a dynamic variable rather than the param? Taken from the groovyConsole AST view for above:\r\norg.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'Math.signum(a <=> b) == result', 9, 9, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(8), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(6), java.lang.Math.$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), 'signum')($spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(4), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), a) <=> $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(3), b)))) == $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(7), result)))\r\n "}}
other: {"actor":{"display_login":"paulk-asert"}}