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 2018/09/03 02:15:00 UTC
[jira] [Comment Edited] (GROOVY-8602) Safe index doesn't work with
map arguments
[ https://issues.apache.org/jira/browse/GROOVY-8602?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601736#comment-16601736 ]
Paul King edited comment on GROOVY-8602 at 9/3/18 2:14 AM:
-----------------------------------------------------------
Reducing priority. The only place map indexing is allowed is immediately after a class constant, e.g.:
{code}
assert Date[year: 118, month: 8, date: 3].day == 1
{code}
I don't see a lot of value in supporting this:
{code}
assert Date?[year: 118, month: 8, date: 3].day == 1
{code}
If we supported using a class variable, I could see the value, e.g.:
{code}
def d = Date
assert d[year: 118, month: 8, date: 3].day == 1 // No map entry allowed at this place
{code}
But we don't support this. You could perhaps argue for a slightly better error message in the Date? case above.
was (Author: paulk):
Reducing priority. The only place map indexing is allowed is immediately after a class constant, e.g.:
{code}
assert Date[year: 118, month: 8, date: 3].day == 1
{code}
I don't see a lot of value in supporting this:
{code}
assert Date?[year: 118, month: 8, date: 3].day == 1
{code}
If we supported using a class variable, I could see the value, e.g.:
{code}
def d = Date
assert d[year: 118, month: 8, date: 3].day == 1 // No map entry allowed at this place
{code}
But we don't support this. You could perhaps argue for a slightly better error message in this case.
> Safe index doesn't work with map arguments
> ------------------------------------------
>
> Key: GROOVY-8602
> URL: https://issues.apache.org/jira/browse/GROOVY-8602
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 3.0.0-alpha-2
> Reporter: Daniil Ovchinnikov
> Priority: Minor
>
> {{a[b:2]}} works.
> {{a?[b:2]}} produces {{Unexpected input: '<EOF>'; Expecting ':' @ ...}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)