groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Sun (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8212) coerce GString to String when used as Map key
Date Fri, 27 Jul 2018 22:02:00 GMT

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

Daniel Sun commented on GROOVY-8212:
------------------------------------

https://github.com/apache/groovy/pull/708
As you see, the PR is rejected to merge... so the issue still exists...

> coerce GString to String when used as Map key
> ---------------------------------------------
>
>                 Key: GROOVY-8212
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8212
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 2.4.10
>            Reporter: Christopher Smith
>            Assignee: Daniel Sun
>            Priority: Minor
>             Fix For: 3.0.0-alpha-3
>
>
> When a GString is used as the key for a bracket-style map get (in this case, from an
overly verbose CSV file):
> {code}
> row["$param URL"]
> {code}
> the {{GStringImpl}} object is passed directly to {{Map#get(Object)}}. Since GStrings
are never equal to Strings, this means that the get will always return null.
> If {{row}} is explicitly declared as a {{Map<String,?>}}, however, Groovy ought
to identify the intended behavior (using a templated string as a map key) and use the string
value instead.
> The current behavior is a problem because even in static compilation mode, where the
generic key bound is known, Groovy does not complain about the use of a GString here (because
it normally treats GStrings as valid for {{String}} targets?), but the lookup will fail at
runtime.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message