You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/08/14 09:56:00 UTC

[jira] [Comment Edited] (GROOVY-8287) Casting a Matcher to Boolean changes behaviour between 2.3.7 and 2.4.12 (or maybe it's the precedence of a cast changing?)

    [ https://issues.apache.org/jira/browse/GROOVY-8287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16125478#comment-16125478 ] 

Paul King edited comment on GROOVY-8287 at 8/14/17 9:55 AM:
------------------------------------------------------------

Yes, the new behavior is expected. See GROOVY-5185 which was fixed in 2.4.4.
See also: http://groovy-lang.org/changelogs/changelog-2.4.4.html
It would have been nice had this been found in time for 2.4.0 but it wasn't discovered (or at least fixed) until later.


was (Author: paulk):
Yes, the new behavior is expected. See GROOVY-5185 which was fixed in 2.4.4.

> Casting a Matcher to Boolean changes behaviour between 2.3.7 and 2.4.12 (or maybe it's the precedence of a cast changing?)
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8287
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8287
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Matt Sheppard
>
> Ran across some old code which was failing after a groovy version upgrade, and boiled it down to this difference.
> {noformat}
> $ tools/groovy/bin/groovy -v
> Groovy Version: 2.3.7 JVM: 1.8.0_25 Vendor: Oracle Corporation OS: Linux
> $ tools/groovy/bin/groovy -e "def result = ((Boolean) 'are you a foolish fool?' =~ 'fool'); if (result) {println 'true'} else {println 'false'}"
> true
> {noformat}
> vs
> {noformat}
> $ tools/groovy/bin/groovy -v
> Groovy Version: 2.4.12 JVM: 1.8.0_141 Vendor: Oracle Corporation OS: Linux
> $ tools/groovy/bin/groovy -e "def result = ((Boolean) 'are you a foolish fool?' =~ 'fool'); if (result) {println 'true'} else {println 'false'}"
> false
> {noformat}
> Basically, the result of casting the Matcher returned by the '=~' operator to a Boolean used to give me what seems to be the result of calling 'find()' on the matcher, where as the new version seems to always return false.
> Is that change in behaviour between versions expected, or is it a bug?
> Nothing on http://groovy-lang.org/changelogs/changelog-2.4.0.html jumped out at me as related.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)